You are not logged in.
I would like to migrate a cron job that I had set up to run mythfilldatabase (followed by another script) daily at 6AM, into a SystemD timer job. I would like the job to be run under a particular user (called mythtv), even though that user may be logged out & no other user be logged in. These are the files I have created:
/etc/systemd/system/mythfilldatabase.service:
[Unit]
Description=Runs mythfilldatabase, then hd_update.sh under the mythtv user
[Service]
Type=oneshot
User=mythtv
ExecStart=/usr/bin/mythfilldatabase --only-update-guide --refresh 0 --refresh 1 --refresh 2
ExecPost=/home/mythtv/hd_update.sh #Script to be run after mythfilldatabase completes - whether sucessful or not.
/etc/systemd/system/mythfilldatabase.timer
[Unit]
Description=Runs mythfilldatabase at 6AM every day
[Timer]
OnCalendar=*-*-* 06:00:00
However while mythfilldatabase runs, it errors as it is either unable to access the grabber script (stored in /usr/bin/site_perl) or unable to access my XMLTV config file stored in /mythtv/.mythtv/Satellite.xmltv
I don't get these errors when I run the command manually when logged in. /usr/bin/site_perl is stored within my PATH variable in /etc/profile so it should be able to access the grabber OK.
Can anyone help?
It turns out that despite the path in /etc/profile being different, if I echo $PATH out my hd_update script, it only gives me: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" which would explain why Mythfilldatabase is running. How can I alter that version of PATH permanently?
Last edited by bergqvistjl (2015-09-10 08:52:29)
Offline
You are not getting a full login shell (/etc/profile ~.bashrc are not sourced)
Easiest way is to add an Environment line something like
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/bin/site_perl/
Offline
or use
EnvironmentFile=/etc/profile
man systemd.exec(5) has details of those options.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline