CentOS 5.11 Startup Script

General support questions including new installations
Post Reply
Positron
Posts: 11
Joined: 2014/10/06 11:48:17

CentOS 5.11 Startup Script

Post by Positron » 2015/05/15 01:31:44

Hello,

I created two scripts which I run manually after reboot and they work till the next reboot.

Code: Select all

nohup /root/first.sh </dev/null &>/dev/null &
nohup /root/secondary.sh </dev/null &>/dev/null &
But sometimes I forgot to run those two commands after reboot. How can I make those two commands automatically run, like at the startup of the system?

Cheer

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CentOS 5.11 Startup Script

Post by TrevorH » 2015/05/15 07:52:09

You either write a proper initscript to run that for you (you can base it off one of the existing scripts in /etc/init.d) or you create an @reboot crontab entry for the user you want to run it. Use man 5 crontab to find out more details.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: CentOS 5.11 Startup Script

Post by gerald_clark » 2015/05/15 12:54:45

Or add it to rc.local.

Positron
Posts: 11
Joined: 2014/10/06 11:48:17

Re: CentOS 5.11 Startup Script

Post by Positron » 2015/05/15 13:50:33

Thanks guys for your help.

I added into crontab as this:

Code: Select all

@reboot bash /root/additional_security.sh start
It works fine now. But on net, I saw that this may not work for "cold startup". I am not sure what "cold startup" is. I am running a CentOS VPS on a hosting company. I did not there is no cold startup for my scenario, right?

Also I am listening netstat and access_log by this script. Do you think it is safe to assume to run this script automatically at the reboot time? Would there be any race condition? I do not check actually if netstat is running or not inside the script, just assuming it is.

Cheers

Post Reply