Add a cron job that logs its output
save cron job output to file | add cron job from command line | log cron job errors | append to crontab without editor | crontab | log | cron-jobsCaution: This command changes the system. Understand what it does before you run it.
(crontab -l 2>/dev/null; echo "*/15 * * * * /usr/bin/php /var/www/vhosts/example.com/httpdocs/wp-cron.php >> /var/www/vhosts/example.com/logs/wp-cron.log 2>&1") | crontab -Reads the existing crontab, appends a new line and writes everything back without opening an editor. >> file 2>&1 appends normal output and error messages to the log file, so you can later see what the job did. Without redirection, cron tries to send the output by mail, which goes nowhere on many servers.
Note: Running it twice creates the job twice. Back up and check with crontab -l first; the log file must be writable by the user.
Also searched as
- save cron job output to file
- add cron job from command line
- log cron job errors
- append to crontab without editor