Ad

How To Use Cronjob In Octobercms?

- 1 answer

Lets suppose i want to delete record with id= 50 from my database with the help of cronjob in octobercms what are steps to do this

i did following things to achieve this
1)- In my plugin i put the following code

   public function registerSchedule($schedule)
{
    $schedule->call(function() {
         DB::table('fsz_posting_tblposting')->where('id', '==', 50)->delete();
    }); // Defaults to every minute (every execution)
}

2)- In my cronjob area of the server i put the following cronjob command

/usr/local/bin/php -q /home3/user/public_html/artisan scheduled:run

After doing these two steps my record is not deleted and i got the following email in my inbox

There are no commands defined in the "scheduled" namespace. Did you mean this?
schedule

what should i do now?

Ad

Answer

Seems some typo in your crontab entry

its schedule:run not scheduled:run[schedule]

Corrected entry :

/usr/local/bin/php -q /home3/user/public_html/artisan schedule:run

for more information you can referhere:

Setup :https://octobercms.com/docs/setup/installation#crontab-setup

How to add task :https://octobercms.com/docs/plugin/scheduling

if any doubts please comment.

Ad
source: stackoverflow.com
Ad