Reputation: 21
I've been trying to put together a very simple shell script that starts redshift, if it is not already running.
#!/bin/sh
if ps -ef | grep -v grep | grep redshift-gtk; then
exit 0
else
/usr/bin/redshift-gtk &
exit 0
fi
I've tried running the script multiple times and I'm sure it works.
I am running Manjaro i3 btw. I've then tried creating a service and timer in /usr/lib/systemd/system/:
/usr/lib/systemd/system/redshift.service
[Unit]
Description=Runs redshift
[Service]
Type=simple
ExecStart=/bin/bash /home/velo/reshift.sh
[Install]
WantedBy=multi-user.target
Yes, the name of the script is reshift.
/usr/lib/systemd/system/redshift.timer
[Unit]
Description=Runs redshift at given intervals
Requires=redshift.service
[Timer]
OnCalendar=*-*-* *:45:00
Persistent=true
Unit=redshift.service
[Install]
WantedBy=multi-user.target
The timer has been changed to whatever relevant minute mark was close by to trigger it. After each change in OnCalender, I've done:
>systemctl daemon-restart
>systemctl restart redshift.timer
>systemctl status redshift.timer
Where I'm told that it is running and enabled. Problem is, nothing is executed whenever the timer hits the mark. Any idea what I'm doing wrong?
Upvotes: 1
Views: 3341
Reputation: 13381
Use systemctl list-timers --all
to check the status of your timers.
Use systemctl start redshift.timer
to start your timer.
Also, you should put your custom scripts under /etc/systemd/system
. The /usr/lib
location is intended for scripts installed by packages.
See also: Run script every 30 minutes with systemd
Upvotes: 1