I'm not familiar with cron at all, and I've looked it up and am still confused as to how specifically it works. I'm on CentOS 6.5, and I need to end a process and then start it again every 12 hours. It will have a different pid every time though, so I'm not sure how I would kill the process. Then I need to restart the process. I would like for this to happen at 7am and 7pm every day.

How would I go about accomplishing this?

EDIT: I need to do this because we're running crtmpserver and it seems to quit after 15 hours or so. If it's restarted it bypasses this problem. Instead of figuring out the root problem I'd rather implement this since it should be a quick fix.

  • 1
    Why you need to do this?
    – Braiam
    Aug 7, 2014 at 12:29
  • What process is it? You can kill on process name (as opposed to pid) with pkill. Or alternatively you could write a script that launches the process and kills it after 12 hours.
    – Sparhawk
    Aug 7, 2014 at 12:32
  • @Braiam: Just updated the OP with that info. @Sparhawk: I didn't know about pkill. The command I use (and the command that shows up in ps aux) is <command> <argument>, would I need to just pkill <command> or the full string? Also, how would I accomplish it via cron?
    – vaindil
    Aug 7, 2014 at 12:37
  • Additional info: I just tried pkill <command>, and it appeared to succeed but the process is still running. pkill <command> <argument> returns a syntax error for the pkill command.
    – vaindil
    Aug 7, 2014 at 12:42

1 Answer 1


Make a cron file for root via sudo crontab -e, add the line:

0 0,12 * * * /etc/init.d/crtmpserver restart

This will restart the server each day on 00:00 and 12:00. Change the '0' and '12' to make it happen at different times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.