Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I tail the running cron job, so that I can come to the conclusion that my job is going on.

share|improve this question

migrated from stackoverflow.com May 17 '11 at 10:41

This question came from our site for professional and enthusiast programmers.

2 Answers 2

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.

share|improve this answer
    
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?? –  Srikk May 17 '11 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. –  ripat May 17 '11 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.