cron job
Hi
i am using centos 5.5 i have a couple of cron jobs running, some of them take about 20min to execute, i need to check the status of this jobs running. if they are currently being executed or they finish executing. i went on the net there is a command "jobs". can this be used ,how to use it. please help |
Hello,
Also found on the net: Quote:
Code:
pidof name_of_your_command Kind regards, Eric |
The cron daemon already logs starting jobs in /var/log/cron. So you could include a line "logger -p cron.info -t "Starting jobname $$";" near the top of the cronjob and "logger -p cron.info -t "Exiting jobname $$";" near the end. The "$$" is the PID of the cronjob shell script, so any processes it starts should have their $PPID value set to this which makes it easier to search for using 'pgrep -lP $PPID'. Another reason to favor 'pgrep' over 'pidof' is that pgrep can use wildcards so running for instance 'pgrep -l cro*' will list any process that has the string "cro" in its process name. Finally, if you don't want to or can't modify your cronjob(s) but you can edit /usr/bin/run-parts and your cronjob or jobs are part of one of the default /etc/cron.{hourly,daily,weekly,monthly} directories /etc/crontab runs you could edit /usr/bin/run-parts to include logging jobs (in kinda-like-diff style):
Code:
if [ -x $i ]; then |
Hi,
Thanks for pointing out pgrep unSpawn, yet learned something new :-) Kind regards, Eric |
All times are GMT -5. The time now is 11:39 PM. |