Linux Start up script!!
Dear Linux users,
I am into theoretical stuff and my job demands me to submit some runs on linux machine which goes on for months. In case of power failure I have to restart these runs! Now e.g. if I am running 50 loops then 49th loop is dependent on 48th and so on!! While restarting I have to use the latest file!! say 49th file using 48th as an input!! Now my problem is whenever I am away for sometime although the system is up by somebody but my jobs dont!! Is it possible in linux to use a script which runs automatically when the machine is restarted and read these loops also!! suggest me something as this really has put me in lots of trouble!!! MzZt!! |
suppose you name your scripts like loop1.ksh, loop2.ksh ... loop50.ksh; after a completion of each script you can add an indicator to show which script has been finished for example: on each loop file add something like echo "Script No" > Out_File then read that file on your startup script and use some for/while loops starting at the output of your Out_File till the end of your scripts, like:
#!/bin/bash X=`cat Out_File` for ((i="$X"; i <=50; i++)); do bash -x loop"$i".ksh done I hope this help a little, |
Please supply your distro name & version.
If you only want it restarted at boot, the usual thing is to add it to the /etc/rc.local file (or the equiv on your system) eg nohup /path/to/yourprog >/path/to/yourprog.log 2>&1 & Then each time your prog starts, it has to check to see what the last completed loop did, so it needs to write or update a temp file or something like that at the end of each loop. |
thanks a lot for your replies!!
I am using RH9. I have a couple of file say e.g.: test1.tpp test2.tpp test3.tpp test.inp test.log test4.tpp (incomplete loop e.g. becoz of power failure) Now my problem is whenever there is a power failure the system gets restarted! So I have to find out which is the incomplete file (test.inp has already defined the loops upto say 50) i.e. test4.tpp from above! then I have to modify test.inp manually at two places and make the latest "complete" file i.e. test3.tpp as an input and restart test.inp to write test_restart4.log, for five power failures I have to do this task five times each time locating the newest complete file and entering it as an input to test.inp and writing different restarts.log everytime. In case I am away then my jobs doesn't run! That is why I wish to write a script and also start that script at the time of boot up so that I can ask anybody to restart the machine and then my jobs wud start up automatically with the modifications listed above! thanks again for reading my query and responding promptly :-) MzZt... |
Like i said, you need your prog to write 'loop completion' msg at the end of each loop to a completion file (see below), then, when it restarts, it can tell where it got to last time eg
test.completion --------------- 37 completed then your prog just grabs that num and starts at 38. Edit: Power comment: If your system is having power failures that much you need to talk to your power supplier and/or get a UPS. Your hardware will die much faster the more often it dies/reboots. |
Dear all!!
Hie!! My problem is solved and the script is indeed running even after restarting the machine taking the current loop as input!! But I have another problem!! There are some servers where I don't have access to /etc/rc.local file since I do not have root password!! So there I cannot run my scripts!! Is there any way out of this situation!!? MzZt... |
If the server has cron you could add the script to your crontab. You'd need to add a check to see if the script is already running though :)
|
But will cron solve my purpose? I need to run the script only if there is a power failure, also it appears crontab editing too require superuser password.
Any other way of running the shell script without superuser intervention? MzZt... |
You should be able to write the checks for powerfailure into the script.
"crontab -e" should work without being a superuser |
All times are GMT -5. The time now is 09:04 AM. |