As an example, take the phpsessionclean schedule. The cron.d file for this looks like this:

09,39 *     * * *     root   [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi

It's saying if systemd doesn't exist on the system run the script /usr/lib/php/sessionclean.

If systemd does exist it doesn't run and the systemd timer runs instead. The phpsessionclean.timer file looks like this:

Description=Clean PHP session files every 30 mins

OnCalendar=*-*-* *:09,39:00


I read about creating your own .timer files and creating an associated .service file containing the details of the script you're running, but in this case, and in the case of other .timer files installed by packages (such as certbot, apt etc.) there are no associated .service files. So, how do I infer what command is going to be executed when this timer runs?

1 Answer 1


You could be looking in the wrong place. Units can be in several places.

$ systemctl cat systemd-tmpfiles-clean.service
# /lib/systemd/system/systemd-tmpfiles-clean.service

(you can also see a command here:

$ systemctl status systemd-tmpfiles-clean.service
● systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
   Loaded: loaded (/lib/systemd/system/systemd-tmpfiles-clean.service; static)
   Active: inactive (dead) since Sun 2017-07-16 17:34:00 BST; 16h ago
     Docs: man:tmpfiles.d(5)
  Process: 28580 ExecStart=/bin/systemd-tmpfiles --clean (code=exited, status=0/SUCCESS)
 Main PID: 28580 (code=exited, status=0/SUCCESS)

To doublecheck the associated service:

$ systemctl show -p Unit systemd-tmpfiles-clean.timer
  • 1
    OK, thanks. I found the service file in /lib/systemd/, was looking in /etc/systemd originally. I also noticed while trying out your examples that there is another column to the output of systemctl list-timers giving the service files names that was getting truncated in my terminal window originally.
    – Darren
    Jul 17, 2017 at 9:37

You must log in to answer this question.

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