-1

I'd like my cronjob to run every 5 minutes. It should execute a command which a user can only run from a certain directory.

In my:/home/alias/laravel/ directory, I can manually run (as user alias) the command php artisan watch:run and a script I've created runs perfectly.

So I want a setup where this runs every 5 minutes. As user alias, I execute crontab -e. At the bottom of that file I add the following:

*/5 * * * * /usr/bin/php /home/alias/laravel/php artisan watch:run

I know the job is executing evey 5 minutes, because I'm getting a mail with:

Cron <alias@mybox> /usr/bin/php /home/alias/laravel/php artisan watch:run (failed)

After some searching, I found that I can see the logs at /var/syslogs, which, amoung loads of other things show:

Oct  4 10:25:01 mybox /USR/SBIN/CRON[8176]: (alias) CMD (/usr/bin/php /home/alias/laravel/php artisan watch:run)


Oct  4 10:25:01 mybox  /USR/SBIN/CRON[8172]: (CRON) error (grandchild #8176 failed with exit status 1)

So first off:

  1. Does anyone know why this command isn't running? I've also tried removing the php from php artisan watch:run... Same thing happens.
  2. Where in my system am I able to send the cron logs to a better place? I've seen answers for systems not Debian.

Thanks!

Alias
  • 101
  • 3
  • I think this is more of an SU question than an SF question. If you look carefully at your cron command there is an obvious mistake in that you're trying to run `/home/alias/laravel/php` with the parameters `artisan watch:run`. You should also take a look at http://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it – user9517 Oct 04 '13 at 08:40
  • Can your script do dome debugging or at least say something? Cron environment is totally different from a user environment and you can be missing different things like running from another directory or executing commands that are not in the path. If the script says nothing maybe it's working correctly? – kworr Oct 04 '13 at 08:55

1 Answers1

3

You are running different commands form shell and cron, why you added /home/alias/laravel/php to crontab command?

if you want to change directory in cron job, just do it

cd /home/alias/laravel/ ;php artisan watch:run