I am working on a program that can "upgrade itself" by install a new package. In order to accomplish this, I am using the at command to specify that a shell script should be run one minute in the future and the shell script, in turn, will install the package. I would really like this to execute sooner than one minute into the future but that appears to be the best that I can do based upon what I have read in the man page for at. Is there a way to do this with tighter resolution?
|
|
||||
|
It would be easier to simply launch the program directly and have it run the update immediately (or it could sleep for some small delay if you really needed it to). If this is in a script itself (eg, bash), simply call the update script directly (likely redirecting the output):
If it's in a program, you can always use the system() call to do the same thing:
|
|||||
|
|
Fork a script that waits for a few seconds.
If your goal is to do the upgrade as soon as your program exits, but no sooner, arrange for your program to terminate by calling |
|||
|
|
|
This depends on what you program is doing. For daemons it is done the following way:
|
|||
|
|

exit(code). – Keith Jun 9 '11 at 16:13batch. But why wouldn't you just run update code in the same process or in a child one? – alex Jun 9 '11 at 16:42SIGHUPto it's child processes, hence your update script will terminate prematurely. Usenohupcommand to protect your script. – alex Jun 11 '11 at 6:22