Ubuntu – Deleting /tmp/ before systemd service

bootsystemdtmp

When the power of my machine is cut off the system doesnt have time to delete /tmp/.

How can I make sure the tmp folder is cleared before a systemd service is run?

Best Answer

Create a script to clean the folder you want or to do whatever you need and put it in /usr/bin/ and then create a systemd service as:

[Unit]
Description=OLPC Configuration
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=base.target

[Service]
Type=oneshot
ExecStart=/usr/bin/yourscript.sh

[Install]
WantedBy=base.target