LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   crontab test (https://www.linuxquestions.org/questions/%2Absd-17/crontab-test-550745/)

JROCK1980 05-02-2007 03:04 PM

crontab test
 
How can I test my crontab? Is there a command I can run to test it?

weibullguy 05-02-2007 03:42 PM

What kind of test? Here's some things I do...
  • Is cron running? ---> Run ps ax | grep cron and make sure it shows up!
  • Is cron working? ---> Try: * * * * * /bin/echo "foobar" >> /file_you_own and make sure it works.
  • Is your command working? ---> Try: * * * * * /bin/foobar > /file_you_own 2>&1 and look for errors in /file_you_own
  • Can cron run your job? ---> Check the cron log, usually /var/log/cron.log or /var/log/messages for errors

x_terminat_or_3 05-02-2007 03:43 PM

It is very easy. All you have to do is think logically

1st place to look is in the logs.

On Redhat, and variants, the file to examine is /var/log/cron I am not sure about its whereabouts on Debian, but I'd suspect it's pretty much the same.

Try

Code:

tail /var/log/cron
To see the last few lines of that file.

That file is basically a list with the times and commands that cron executed.

Another option would be to add a line to your crontab like this

Code:

* * * * * wall test
If your cron works, then after two minutes, you will see the word test appear on your console every minute

WantLinuxHelp 12-01-2011 12:37 PM

For me under Ubuntu 11.04, "wall test" failed. This worked, though


Code:

* * * * * echo "Cron Worked $(date)" >> /tmp/cronworked.txt
And then look for tile /tmp/cronworked.txt

Under Ubuntu, if it did NOT work, errors are in /var/log/syslog

tgs78 09-24-2012 02:35 PM

Linux cron job scheduling
 
An article explaining the Linux cronjob scheduling with the help of examples.

http://www.thegeekscope.com/linux-cron-job-scheduler/

Hope you will find this post useful !


All times are GMT -5. The time now is 05:38 AM.