Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Many years ago, we can write our startup-script into /etc/rc.local. After all system services loaded, your script will run.

Now, we use systemd, we don't have rc.local anymore. Systemd starts the service parallel. You can write your own service to act a rc.local` but you can't ensure it will run after all system services loaded.

Is there a way to do it? Or we have to use Before and After in the systemd service file?

share|improve this question
Systemd, not Upstart!! – 比尔盖子 Jan 31 '13 at 9:46
Specify name and version OS? – STTR Jan 31 '13 at 9:59
OS: Arch Linux, Version: N/A – 比尔盖子 Jan 31 '13 at 10:02
@比尔盖子 Why "last", do you not know the dependencies of the script, or do you want it last just to be safe? – Paul Jan 31 '13 at 13:05
up vote 12 down vote accepted

In systemd it is advised to use Before= and After= to order your services nicely around the other ones.

But since you asked for a way without using Before and After, you can use:


which as man systemd.service explains

is very similar to simple, however actual execution of the service binary is delayed until all jobs are dispatched. This may be used to avoid interleaving of output of shell services with the status output on the console.

share|improve this answer
Hi, would you care to elaborate the syntax if I was gonna use before or after? – r4ccoon Dec 28 '15 at 21:43

I'm not familiar with the specifics or ArchLinux, but here is how to manage systemd in general.

Well, basically systemd is a collection of scripts in /etc/init.d/ that are pointed by symlinks from /etc/rcX.d, where X is the number of run level. Symlinks themselves are of the following format:

[K | S] + nn + [string]


  • nn is a number that determines the order in which those scripts run
  • string is the name of the script as it appears in /etc/init.d/
  • and finally K or S determine the command that the script is invoked with: stop or start respectively.

So, if you want your script to run last in the boot sequence, you need to do the following:

  1. put your script in /etc/init.d/ and make it executable
  2. determine the target runlevel the script should start at (tipically 2 for console and 5 for graphical user interface). Can be determined with something like runlevel
  3. have a look at what scripts are already there in this runlevel ls /etc/rc<target runlevel>.d/ and choose a two-digit number that is greater than any other already there.
  4. using an utility specific to your distribution like update-rc.d for Debian based or chkconfig for Fedora-like or manually, create a symlink /etc/rc.d/S to your init script.
share|improve this answer
What you've described is actually sysVinit. While it is true that systemd is compatible with how sysVinit worked, there is one key difference - everything is performed in parallel. There are also two types of services, sysVinit services, and systemd services. Your answer may help something execute after the sysVinit services, but not necessarily the systemd ones. – Sam Jul 26 '13 at 12:32
Systemd does not aim to be compatible with sysvinit at all, from the day one. – lzap Dec 18 '13 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .