I have a question regarding a programm I run. Every once in a while, I need to restart a certain program.
For that case, I usually run:
screen ./run.sh arg1 arg2 "arg3"
(screen, since I don't know if there is another way of putting something in the background – but that's another thing.)
So, I think I could add a cronjob which (via crontab -e
) which runs this program (do I need a bash-script for that though?) – But I don't know how to stop the process. Right now I'm cancelling it via CTRL + C after I re-attached the detached session.
I was thinking of kill
ing it, but I don't know the process-id when I start program. Can someone help me with that? I'm using Ubuntu 12.04.
tl;dr
start the process
wait 6 mins
stop the process,
(re)start the process (…)
Thanks
Best Answer
If you are not opposing
bash
solutions, here's a script that does what you outlined. It can be added to/etc/rc.local
to run on every boot. Just call it likebash /path/to/script &
from within/etc/rc.local