I have a cronjob set up like so:
~> crontab -l
0 * * * * /bin/bash -l -c 'cd /mnt/hgfs/kodiak && RAILS_ENV=test bundle exec
rake nightly_tasks --silent 2>> ./log/tasks_errors.log'
I can see that the cron job is running because it is being logged and the log is being updated. However when I use ps
or ps -ef | grep cron
I don't see the running job:
~> ps -ef | grep cron
root 4228 1 0 09:14 ? 00:00:00 cron
user 4233 3545 0 09:14 pts/3 00:00:00 grep --color=auto cron
I tried that same command with grep rake
and didn't see rake in the list. I did try killing pid 4228 but it didn't stop the rake job from running. Killed it 3 or 4 times and still was seeing output in the logs (and the rake task went to the end).
How can I kill this cron job? It runs on the hour and takes about 20 mins to run (it does a lot and is running hourly because I'm testing it). I'm troubleshooting it and I'd like to kill it if it isn't running correctly, which I can see in the logs.
Best Answer
I think cron spawns the job, so you wouldn't have a "cron" process related to that. I'd try
ps wwuxa |grep rake
. You say you already did? the process has to be there like you mention, I think you're doing it right, you may want to try with my "wwuxa" thing for ps just to cover all your bases.