I have a Linux machine that I want to leave unattended. I have a program on this machine that I want to automatically start when the machine boots up and runs unattended.

What is the best way to configure this program to start on startup? I don't have any sort of GUI installed, so can't use gnome-session-properties or anything along that sort of line. Do I have to configure an automatic login to a special autonomous user? If the program can run without having first logged in as a user, what memory can it write to and where can it store text files it needs?

  • 2
    it would really help to mention which distro you're using. Assuming we start this up with an init script, there are 3 different systems in use today, and the answer will need to take into account of that. – Journeyman Geek Sep 21 '12 at 15:02
  • @JourneymanGeek do you happen to have a link describing the differences between the three and by which distro they are used? – Baarn Sep 21 '12 at 15:04
  • offhand, no. init.d is the 'old' system. Upstart and startd and alternatives used by ubuntu and fedora respectively. I think the latter can run init scripts, but its very hard to answer without knowing. – Journeyman Geek Sep 21 '12 at 15:07
  • Sorry. Using Fedora. – Froskoy Sep 21 '12 at 15:25
  • @JourneymanGeek surely you meant systemd? In which case I'd advise looking at the archwiki systemd page here wiki.archlinux.org/index.php/… – Rob Sep 21 '12 at 16:22

For systemd (which is what fedora uses), the archwiki provides a solution like this:

Create a new file in /etc/systemd/system (e.g. myscript.service) and add the following contents:

Description=My script




# systemctl enable myscript.service

This example assumes you want your script to start up when the target multi-user is launched.

  • Thanks. Since this process isn't then associated with a user, where can it write/read text files? – Froskoy Sep 21 '12 at 17:43
  • It will be run as superuser if I'm not mistaken. You can have it run as a user by setting uid for it properly I think. That's something you'd have to look up as I've never done it. – Rob Sep 23 '12 at 20:19

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.