HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

crontab log

 
rajesh73
Super Advisor

crontab log

how to check my cron job running status

1 REPLY
Matti_Kurkela
Honored Contributor

Re: crontab log

If your cron job does not do anything to make itself easier to find, your options are to read the cron logfile (/var/adm/cron/log) or use the ps command (like "ps -fu <username>") to see if it is currently running.

 

If you don't redirect the standard output and/or standard error output of the cron job, the output will by default be mailed to you (if the mail system has default configuration, it will end up to your local email inbox file, /var/mail/<username>).

 

If your cron job is a script, you can make it easier to find by adding a command like this to the beginning of the script:

echo "$$" >/some/file.pid

 

This creates a pid file for the job, which allows you to make several checks:

  • If /some/file.pid exists, the cron job has been started at least once
  • the timestamp of the file will tell you the last time the cron job actually started
  • "ps -fp $(</some/file.pid)" will list the cron job process if it is still running
  • if you need some other script to know if the cron job is currently running, you can do it like this:
#!/bin/sh

# kill -0 only tests if a given PID exists
if kill -0 $(</some/file.pid); then
    echo "Yes, the job is still running."
else
    echo "No, the job is not running right now."
fi

 

MK