List currently running cron tab and stop it

Shame that in this and other pages listed in google results on how ot deal with hung cron jobs that noone ever mentions pstree.

pstree

Look under cron part of the tree


I think if a shell-script wrapper is around that should timeout the cronjob, if it is running for a lengthy arbitrarily enough long periods of time. The wrapper should send the SIGHUP or SIGALARM when the timeout happens from the period the cronjob is invoked. Something like this:

50 * * * * /usr/bin/my_cron_wrapper_timeout -t 1 /usr/bin/my_command_cron_job_to_run

This cron_wrapper_timeout should basically send the timeout signal once -t switch option 1 hour passes and then should send kill -HUP signal to the cronjob and then make sure to reap the process as well and then end/kill itself.

Or alternatively, the code should be written with in the cronjob itself to handle the ALARM signal timeout and make sure it cleans up before it dies gently.

EDIT

This is exactly what I was referring to: watchdog at http://chihungchan.blogspot.com/2011/03/no-more-hanging-jobs-in-cron.html


You should stop the process that the crontab started running.

#kill -HUP PID (PID: Process ID is the process running)

To see a relation of the PID with the running processes (and more info) use top command, change the column order with the keys < and >

Also try ps -ax|grep [your_process_file] which lists the running processes filtered by the name you choose

-HUP = Hang UP

Tags:

Linux

Cron