How can I tail the running cron job, so that I can come to the conclusion that my job is going on.
2 Answers
In your script you could echo something like echo 'My job started on: ' $(date)
and in your cron, redirect both the stdout and the stderr to a file:
* * * * * /path/to/your/job &>/tmp/MyJobLog
If you want to check 'live' what your job is doing, just do tail -f /tmp/MyJobLog
Another option is to log the start (or the end) of your script in syslog with the logger
command if supported by your distro.
-
Here the /path/to/your/job means the location of the cron file or the location of the script which I enter in the cron file??– SrikkMay 17, 2011 at 8:36
-
This is the path to your script. It is highly recommended to always specify full path to all scripts and commands in the cron file as it usually has no value for the
PATH
environment variable unless specifically set in the cron file.– ripatMay 17, 2011 at 9:23
You need to find out the PID of your job:
ps ax | grep jobname
After that you can check if your job is working, by tracing its actions with strace
.