systemd autorun
systemd is the modern initialization system built-in in most of latest stable releases of Linux
distributives. the main advantage of systemd is the fast and parallel boot of system services.
but for me, the main difficulty with it is an unpredictable order of start my script.
I want to run my autorun script after the last service.
however just specifying the option After=multi-user.target
does not work as I hoped.
my script starts after multi-user.target but among other services which had the same option in the config file.
so, if you want to start your script definitely after the whole system, you should create new runlevel (target) and run your program as a service at this level.
- vim /etc/systemd/system/name_of_the_level.target
[Unit] Description=My own run level Requires=multi-user.target After=multi-user.target AllowIsolate=yes
- vim /etc/systemd/system/startup.service
[Unit] Description=My own service After=name_of_the_level.target [Service] Type=simple ExecStart=/absolute/path/to/the/execution/file [Install] WantedBy=name_of_the_level.target