-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

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