I would like to execute a script every 30 min after booting into the system. I know you can use cron, but I don't plan to use this feature often therefore I'd like to try it with systemd.
So far I have only found the monotonic timers which allows to execute something once (at least I think so). How would the foo.timer
and foo@user.service
look like in case I wanted to execute something every 30 minutes from boot/system start?
foo@user.service
[Unit]
Description=run foo
Wants=foo.timer
[Service]
User=%I
Type=simple
ExecStart=/bin/bash /home/user/script.sh
foo.timer
[Unit]
Description=run foo
[Timer]
where I am stuck... ???
systemctl status test.timer
andsystemctl status test.service
comamand – Reishin Apr 24 '15 at 19:19test.timer
. The status tells me that it is active (running) however nothing is happening. – TomTom Apr 24 '15 at 19:24systemctl list-timers --all
command and check the output. He need to be like this. Look to unit, left and passed columns. If timer is present, please look to your service file and check for bugs there since timer working normally. – Reishin Apr 24 '15 at 19:30/bin/bash script.sh
as well as making the script executable. But unfortunately it doesn't triggernotify-send
which creates notifications inxfce4
– TomTom Apr 24 '15 at 19:46export DISPLAY=:0.0
to the script. – Reishin Apr 24 '15 at 20:26[unit name].[type of service]
i.e. we have unit nametest
with service typesservice
andtimer
. What would be triggered available as well via systemctl status test.timer. So answering bluntly, by filename before dot ... – Reishin Apr 21 '22 at 22:13.timer
will never fire with onlyOnUnitActiveSec=
when itsUnit=.service
isType=oneshot
: https://github.com/systemd/systemd/issues/6680 – n0099 Feb 23 '24 at 12:12