4

Currently I need to have a program running all the time, but when the server is rebooted I need to manually run the program. And sometimes I'm not available when that happens.

I can't use a normal configuration to restart my program when the server is starting because I don't have root access and the administrator don't want to install it.

Aragorn
  • 255

5 Answers5

4

I posted this on a similar question


If you have a cron daemon, one of the predefined cron time hooks is @reboot, which naturally runs when the system starts. Run crontab -e to edit your crontab file, and add a line:

@reboot /your/command/here

I'm told this isn't defined for all cron daemons, so you'll have to check to see if it works on your particular one

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233
3

A more general solution would be to set up a cronjob which checks if your program is running every few minutes. I run dircproxy as regular user and the crontab entry looks like:

*/10 * * * * /path/to/dircproxy_cron.sh

grendel
  • 491
  • 3
  • 3
1

This is not an answer to the general question, but should probably be mentioned.

Unix and Unix-like systems are often employed in multi-user environments since they are multi-user operating systems. Because of this, administrators of such systems are often hesitant to install unknown services or software because it may lead to instability or insecurity for all of the users of the system. Thus, I think the first steps are

  1. Determine why the administrator doesn't want the service installed.
  2. Think about whether you can accomplish the task in some way that would address the administrator's concerns.
  3. If not, determine whether the administrator's concerns are valid. Namely, ask yourself, "Could this cause instability or other users?", "Could this affect performance for other users?", and "Could this leave other users open to security vulnerabilities?"
  4. If the answer to all of those are no, ask yourself whether doing this without the administrators permission could get you into trouble.
  5. If it won't or if you are willing to accept the risk, try one of the methods mentioned above.
Steven D
  • 46,160
0

Even more reliable solution would be to use a monitoring tool like Monit or god that automatically detects that a process is dead and restarts it whether it happened during reboot or not.

You might think that's an overkill but actually the configuration of Monit is a simple as

check process foo with pidfile /var/run/foo.pid
  start program  "foo_start"
  stop program  "foo_stop"
  if 5 restarts within 5 cycles then timeout

Of course the assumption is that the administrator is willing to install the monitoring tool for you so it could be a chicken and egg problem :)

Adam Byrtek
  • 1,339
0

I would recommend http://supervisord.org/ it will supervice your process, restart it for you and has a lot of configuration and should be run as a normal user.

rkthkr
  • 151