0

When I build my server image, I write the following to a temporary file;

* * * * * php /var/www/artisan schedule:run

and then load it with

crontab < /tmp/cron

After deployment of the image, I run cron -f and I can see that the process is indeed running, but the cronjob is not being initiated.

If I run crontab -e, add a space, save it, run crontab -e again and remove the space, the cronjob working just fine without reload of cron.

I've tried reloading the cron on build with /etc/init.d/cron reload, but this does not solve the issue.

Hedam
  • 183
  • 2
  • 8

1 Answers1

0

crontab needs to be notified. You can do something like this to (carefully!) append through the commandline or with a script:

(crontab -l 2>/dev/null; echo "* * * * * php /var/www/artisan schedule:run") | crontab -

The 2>/dev/null; suppresses crontab's message when a user has an empty crontab.

  • That's basically what I already do, which does not work. – Hedam Apr 11 '17 at 14:38
  • Sorry but no, that is not what you basically already do. Please look again at the example command I posted for you. It pipes through to `crontab -` so that crontab will be notified. Nothing in your first example, where you append, notifies crontab. In your second example, you invoke `crontab -e`, which notifies crontab. You need to notify crontab for it to pick up your job. – Diogenes deLight Apr 11 '17 at 16:49
  • `crontab < /tmp/cron` notifies crontab – Hedam Apr 12 '17 at 09:16