- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: finding whether cronjob ran successfully
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 04:59 PM
тАО03-02-2009 04:59 PM
How do we know that a particular cronjob ran successfully ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 05:05 PM
тАО03-02-2009 05:05 PM
Re: finding whether cronjob ran successfully
Examine '/var/adm/cron/log'. The 'rc=' denotes the return (exit) code from the crontask. Non-zero indicates failure; zero is success, by convention.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:19 PM
тАО03-02-2009 08:19 PM
Re: finding whether cronjob ran successfully
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:36 PM
тАО03-02-2009 08:36 PM
Re: finding whether cronjob ran successfully
2>&1 | mail root
in the end of the entry. The log will be sent to root mail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:54 PM
тАО03-02-2009 08:54 PM
Solutionfile (/var/adm/cron/log).
A typical log entry consists of three parts similar to:
> CMD: find / -name core -exec rm -f {} \;
> root 12345 c Wed Apr 4 07:44:00 METDST 2001
< root 12345 c Wed Apr 4 07:46:13 METDST 2001
The two first entries (>) are consecutive. The third entry may not immediately follow the command and start entry (for example there could be information about another cron job starting or ending before this job ended). You can find the third entry (the termination entry) by using the job's PID (since the pid is common to both the start and end entry).
Here in detail is what they mean:
> CMD: find / -name core -exec rm -f {} \;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| command/script name
|
v
'>' command name
> root 12345 c Wed Apr 4 07:44:00 METDST 2001
| | | |
| | | + c=cronjob a=atjob b=batch-job (or d-y - refer to queuedefs(4)
| | +-- command's PID
| +---- username.
v
'>' startup time entry.
< root 12345 c Wed Apr 4 07:46:13 METDST 2001 vv=xx
| | | | \___/
| | | + c=cronjob a=atjob b=batch-job |
| | +-- command's PID |
| +---- username. optional status/termination
v information.
'<' termination time entry.
There are 2 possible formats for this optional information:
- 'rc=xx' This field is added when the exit code of the job is not equal to 0
- 'ts=xx' this is the exit code of the shell used by cron to launch the command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:55 PM
тАО03-02-2009 08:55 PM
Re: finding whether cronjob ran successfully
crontab entry:
* * * * * ll / >/dev/null
> CMD: ll / >/dev/null
> didier 9436 c Wed Apr 4 18:07:00 METDST 2001
< didier 9436 c Wed Apr 4 18:07:00 METDST 2001
B) an example of command that exits with an error.
crontab entry:
* * * * * cat /unexisting_file > /dev/null
> CMD: cat /unexisting_file > /dev/null
> didier 20321 c Wed Apr 4 09:41:00 METDST 2001
< didier 20321 c Wed Apr 4 09:41:00 METDST 2001 rc=2
C) an example of command that terminates when it recieves a signal.
crontbab entry:
* * * * * sleep 12345
$ ps -ef | grep 12345
didier 20844 20843 1 09:43:00 ? 0:00 sleep 12345
didier 20843 25184 2 09:43:00 ? 0:00 sh -c sleep 12345
$ kill -7 12345
> CMD: sleep 12345
> didier 20843 c Wed Apr 4 09:43:00 METDST 2001
< didier 20843 c Wed Apr 4 09:43:20 METDST 2001 rc=135
^^^
135=128+7
rc=135 135=128+7 128 means that the command has made an unexpected exit. 7
represents the signal that caused the unexpected exit.
D) an example of unexpected shell exit.
crontbab entry:
* * * * * sleep 12345
$ ps -ef | grep 12345
didier 21414 25184 0 09:45:00 ? 0:00 sh -c sleep 12345
didier 21416 21414 0 09:45:00 ? 0:00 sleep 12345
$ kill -7 21414
> CMD: sleep 12345
> didier 21414 c Wed Apr 4 09:45:00 METDST 2001
< root 21413 c Wed Apr 4 09:45:00 METDST 2001
< didier 21414 c Wed Apr 4 09:45:16 METDST 2001 ts=7
^^^^
ts=7 This means that the cron shell used to execute the command has made an expected exit due to signal 7
For further reading please look at the man pages for at(1), cron(1M), proto(4),
and queuedefs(4).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:58 PM
тАО03-02-2009 08:58 PM
Re: finding whether cronjob ran successfully
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 08:59 PM
тАО03-02-2009 08:59 PM
Re: finding whether cronjob ran successfully
Cron will always automatically mail output for stdout and stderr to root unless you specifically state in the command that stdout and stderr are redirected elsewhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2009 12:44 AM
тАО03-04-2009 12:44 AM
Re: finding whether cronjob ran successfully
if you don't have redirect the stdout and stderr of teh script all the output are sent to the mail of the user where crontab run.
HTH.
Rgds,
Art