I have a small script on a dev/staging server that runs services inside tmux. The script just creates a few sessions with a few windows each in which various services are running.

How can I make this script run each time the system starts after reboot? I would like to have this script run as specified user.

migrated from serverfault.com Jul 16 '13 at 17:01

This question came from our site for system and network administrators.


The quickest way is to put a command like su - john -c "bla" in /etc/rc.local (or whatever variant your distro uses.

  • 1
    If you want this to be something that exists even if the user closes it then using a daemon monitoring or runlevel/init tool is likely a good idea also. – Etan Reisner Jul 16 '13 at 12:24
  • Yes, I think I should setup init.d scripts for this. – Sławosz Jul 16 '13 at 12:29
  • Above comments is very true. Also remember that if the command run doesn't return, it will hang your rc.local. – Halfgaar Jul 16 '13 at 14:01
  • Unless you use &. – Braiam Jul 16 '13 at 17:05

A more conventional way would be to add a line like this to /etc/crontab


/etc/crontab is:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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