Example:
* * * * * /usr/bin/php /full/path/to/script.php arg1 arg2 > /full/path/to/logfile.log
The script runs and accesses the arguments just fine, but the results are never printed to the logfile.log. Also, my logfile.log is chmod 777, so I know it has write access.
Can you fix my syntax?
Stop searching for logs On Ubuntu, Debian and related distributions, you will find cron jobs logs in /var/log/syslog . Your Syslog contains entries from many operating system components and it's helpful to grep to isolate cron-specific messages.
* * * * * is a cron schedule expression wildcard, meaning your cron job should run every minute of every hour of every day of every month, each day of the week.
Setting Each Variable in the crontab File Similar to the BASH_ENV method mentioned before, we can set any variable writing name=value before the command. If we specify more than one variable, we have to space them with whitespaces in between.
5 * * * * means it runs once per hour at five minutes past the hour. */5 * * * * means it runs once every five minutes.
It looks like you are searching for the log file in the wrong folder. Try this
* * * * * cd /path/to/script.php ; ./script.php arg1 arg2 >> logfile.log
Then look for your log file in the /path/to/script folder. It can also be a write permission problem. Also, check your script for errors. Your crontab command seems OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With