开发者

Nokia N900 - Meego Linux - xterminal - shell script - keep process alive

I need a program in Nokia N900 - Meego Linux - to be always on if it dies it must restart by itself how do i do it?

I would like to use it on 'x11vnc'

also maybe开发者_运维技巧 start the process again if its killed by any other process, restarting itself again


Add your process to /etc/inittab, and let init restart your process when it terminates.

I.e.

mp:2345:respawn:/usr/app/bin/my_process

See inittab(5) for details.

(Credit goes to Lew Pitcher, http://forum.soft32.com/linux2/process-alive-ftopict10675.html)


Using inittab as suggested by blinry is good when you have root access.

When you don't have root access, you can run a shell in screen and have it do this:

$ while true; do run_program; done

This is assuming that your "run_program" script does not go into the background otherwise the loop will keep on spawning instances of "run_program" indefinitely.


I ended up using daemon, which I installed from apt-get. It has an argument -r that should restart my command if it dies. So my final command ended up being:

daemon -u www-data -n arbitrary_name -r -X "ffmpeg blah blah blah"  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜