Knowledgebase

Portal Home > Knowledgebase > Articles Database > How to run this command whenever server reboots or restarts?


How to run this command whenever server reboots or restarts?




Posted by awaisuk, 09-14-2010, 11:54 PM
Hey. How to run this command whenever server reboots or restarts? I want to run a command automatically when a computer restarts or reboots.....Its a command to run my script as I have to do it manually all the time when server goes down sometime. Is there a way to do it somehow?

Posted by InstaCarma_Support, 09-15-2010, 12:43 AM
For a command or a script to get executed at the time of reboot, you can include a @reboot cronjob. The cron job will look like below. @reboot /bin/bash /path-to/script-file

Posted by awaisuk, 09-15-2010, 01:00 AM
I want it executed after the reboot, not before the reboot.....does @reboot does that?

Posted by InstaCarma_Support, 09-15-2010, 01:03 AM
Yeah, @reboot executes the command once the server is up after a restart. Anyway, restarting a service before a reboot is of no point!

Posted by awaisuk, 09-15-2010, 01:57 AM
Ok I have added it in crontab, hopefully it will work. Thanks.

Posted by LVPSHosting, 09-15-2010, 04:24 AM
Just put the command in your /etc/rc.local file

Posted by madaboutlinux, 09-15-2010, 09:21 AM
True, this is a better way to execute a command at the time the server boots up.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language:

Contact us