6 plexupdate.sh systemd timer
constiens edited this page 2019-04-05 09:58:16 -05:00

Assuming the path to plexupdate.sh is /opt/plexupdate/plexupdate.sh

Place the following into /etc/systemd/system/plexupdate.service:

[Unit]
Description=plexupdate
After=network.target
# If plex uses external mounts for media, we might not want to attempt an update (& start plex) if it's not available.
# Requires=mnt-vol_raid.mount

[Service]
ExecStart=/opt/plexupdate/plexupdate.sh --config /etc/plexupdate.conf

And the following into /etc/systemd/system/plexupdate.timer

[Unit]
Description=Run the plex updater daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

Reload systemd, enable the timer and run the service to test:

[root@media-01 ~]# systemctl daemon-reload
[root@media-01 ~]# systemctl start plexupdate.timer
[root@media-01 ~]# systemctl enable plexupdate.timer
Created symlink from /etc/systemd/system/timers.target.wants/plexupdate.timer to /etc/systemd/system/plexupdate.timer.
[root@media-01 ~]# systemctl start plexupdate.service
[root@media-01 ~]# 

Check status of the timer and service:

[root@media-01 system]# systemctl status plexupdate.timer
● plexupdate.timer - Run the plex updater daily
   Loaded: loaded (/etc/systemd/system/plexupdate.timer; enabled; vendor preset: disabled)
   Active: active (waiting) since Sun 2016-12-11 23:24:41 GMT; 29s ago
[root@media-01 system]# systemctl status plexupdate.service
● plexupdate.service - plexupdate
   Loaded: loaded (/etc/systemd/system/plexupdate.service; static; vendor preset: disabled)
   Active: inactive (dead) since Sun 2016-12-11 23:03:32 GMT; 21min ago
 Main PID: 7475 (code=exited, status=5)

Dec 11 23:03:32 media-01.domain.com plexupdate.sh[7475]: Retrieving list of available distributions
Dec 11 23:03:32 media-01.domain.com plexupdate.sh[7475]: Your OS reports the latest version of Plex (plexmediaserver-1.3.2.3112-1751929.x86_64) is already installed. Use -f to force download.
[root@media-01 system]#