Difference between revisions of "Linux: run at startup"

From RHS Wiki
Jump to navigation Jump to search
m (Protected "Linux: run at startup" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 

Latest revision as of 21:12, 8 April 2015

Using crontab

Edit crontab using:

crontab -u otherusername -e

add the line:

@reboot <command>

More info on crontab and cron jobs:
Linux: cron jobs

Creating simlinks with update-rc.d

update-rc.d example:

sudo update-rc.d samba start 15 2 3 4 5 . stop 85 0 1 6 .

This command will start the samba server when the server starts in levels 2, 3, 4, 5
And it won't start when the server starts at levels 0, 1, 6
This is done by creating the simbolic link: S15samba in folders:

  • /etc/rc2.d
  • /etc/rc3.d
  • /etc/rc4.d
  • /etc/rc5.d

And the simbolic link K85samba in folders:

  • /etc/rc0.d
  • /etc/rc1.d
  • /etc/rc6.d

Numbers 15 and 85 are the priority, they are used to start or stop one services before others.
To remove this simbolic links

sudo update-rc.d -f samba remove


Using sysv-rc-conf

First install sysv-rc.conf:

sudo apt-get update && sudo apt-get install sysv-rc