How to see all startup tasks from the command line?

I was trying to find why a certain application ran on my Raspberry Pi, and turns out there is a half dozen ways to execute an application on startup. Here are the ones that I’ve located.

  • /etc/rc.local
  • /home/pi/.bashrc
  • copying a script to /etc/init.d/
  • systemctl
  • schedule via crontab

Is there a way to identify, from the command line, everything that runs (or is scheduled to run) on startup?

Asked By: AngryHacker


Since debian is a systemd-based distro, you get all the nice tools!

So, I’m not only giving you the list of all things that need to be started for your system to be at "I’m done booting!", but also a few examples of other tools you can use to gain a closer understanding of what happened during the last boot.

# Gives you a text-art tree of all the units that get started for
# your default boot target:

sudo systemctl list-dependencies

# Takes the log from the last boot, and analyzes the critical chain, i.e.,
# what the things were the "next thing to happen" waited for the longest.
# For example, for a webserver to start, you might need to wait both for
# network to be up, as well as for the database server to be ready. The
# webserver might be the thing that the multiuser target was waiting for
# the longest, and not the synchronization of mails. 
# This critical chain will show what was "blocking" the system from
# continuing to boot for the most part. It is a useful tool if you want to 
# figure out how to optimize boot speed:

sudo systemd-analyze critical-chain

# Takes the log from the last boot, and list what took how long to
# start (and if it finishes, and isn't persistent, to finish), and
# outputs it as SVG data, which you can look at e.g. in your browser:

sudo systemd-analyze plot > boot-timings.svg

Note that this does only incorporate things that are within "normal" system boot. If you have e.g. a timer (be it through cron or some other means), then systemd can’t know about that. But that’s always been the same – it’s always been a great way of forgetting that you did something to abuse cron as a tool to start things at boot, so Linux distros are quite stringent about not allowing packages to set up cronjobs that aren’t really cronjobs but hidden at-boot starters.

Answered By: Marcus Müller
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.