0

Might have been asked previously, but I can't find a link. How do I make a bunch of commands run as root on startup without having to open the terminal or entering the password?

1 Answers1

2

One way you can try it is by adding your commands to the /etc/crontab file with the @reboot command.

If you run the following command it will load up the file in an editor so you can add the line(s)

sudoedit /etc/crontab

Then how I did it was like so:

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
@reboot         root    /home/terrance/cb_update.bsh
05 1    * * *   root    /home/terrance/cb_update.bsh
#

As you can see my second to last line starts every time the system restarts @reboot then as the root user with my command of /home/terrance/cb_update.bsh. The last line starts at 01:05 in the morning everyday running that script as the root user.

Hope this helps!

Terrance
  • 43,712