Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test run cron entry

I added a cron job recently, but made a mistake in the path while giving the command and hence, the job never succeeded. Is there some way to test the cron changes we have done?

Please note that I had indeed copied and pasted the command from my command line and it was just an stray keypress that caused this.

like image 997
Karthick S Avatar asked Nov 15 '11 06:11

Karthick S


People also ask

How do I test a cron script?

How to test a Cron Job? Open the Corntab – Its an online tool that will help you to Check the Cron time. You can enter the cron time and it will tell you when this cron will trigger. Note down the time and verify if its correct one.

How do I check my cron schedule?

You can find them in /var/spool/cron/crontabs. The tables contain the cron jobs for all users, except the root user. The root user can use the crontab for the whole system. In RedHat-based systems, this file is located at /etc/cron.


1 Answers

When I want to test my cron jobs I usually set the interval very low and monitor the logs closely. When I am convinced the entry is correct, I set the interval back to a sane value.

For example, run job every two minutes:

*/2 * * * * echo "Hello World"

And the I run tail -f on my log file (/var/log/syslogon debian).

like image 72
Martin Olsen Avatar answered Oct 11 '22 17:10

Martin Olsen