Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
  • Run shell script at linux boot (Start up) but only one time per day , How can i do it ?
  • I am using Redhat enterprise linux 5
share|improve this question
    
Are you starting up a server each day, and sometimes more than once a day? I'm having difficulty seeing why. –  Charles Stewart Feb 4 '10 at 8:31
    
@ Charles Stewart , i asked this question for local server ( LAN ) –  Kumar Feb 4 '10 at 9:29
    
Does the whole LAN really get powered up and down once or more a day? –  Charles Stewart Feb 4 '10 at 9:38
    
@ Charles Stewart, We save power, –  Kumar Feb 5 '10 at 4:24

4 Answers 4

up vote 2 down vote accepted

Put your script in the init.d so that it gets executed at boot.

To make sure that it only gets executed once a day, all you need to do is store the date of the previous execution and compare that to the current date. This is quite simple to do in any script language.

share|improve this answer

Add it to init.d. Have the script "touch" a small file to a directory it has access to, a home directory as a non-privileged user (unless it needs other privs). Do not use tmp since you have no guarantees that the file will persist. Name the file with the name of the process, look for it and check the last modification time on it. If its less than 86400 seconds ago, exit, else continue. Do the check prior to "touch"ing the file or you will always think that the script has not run in the last day.

share|improve this answer

On a debian system I would put my script on /etc/cron.daily and just install anacron.

Anacron is probably the tool you are looking for.

Don't know if RHEL includes rpm for or if you'll have to hunt for them or even compile from source.

share|improve this answer

You should use anacron to run this. It's used for things that you want once per day.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.