Overwriting httpd.service PrivateTmp

While setting up Xdebug I had to change the httpd.service systemd unit file to don’t use private tmp dir in /tmp

For locating the unit file I just used

locate httpd.service

Then needed to copy it, edit and reload the daemon config.

sudo cp /usr/lib/systemd/system/httpd.service /etc/systemd/system
sudo vim /etc/systemd/system/httpd.service
sudo systemctl daemon-reload
sudo systemctl restart httpd.service
Advertisements

systemd user timers (cron alternative)

After system reinstall I had some issues fixing my user systemd timers. Because I copied the files from backup to .config/systemd/user/ the system yell at me with Failed to execute operation: Invalid argument
After googling I found solution at http://stackoverflow.com/a/33363732/289404

I had disabled timer-{daily,weekly,hourly}.timer

$ systemctl --user list-unit-files
UNIT FILE                  STATE
dbus.service               indirect
mpd.service                disabled
mpdas.service              enabled 
systemd-bus-proxyd.service static
systemd-exit.service       static
dbus.socket                disabled
systemd-bus-proxyd.socket  static
basic.target               static
bluetooth.target           static
busnames.target            static
default.target             static
exit.target                static
paths.target               static
printer.target             static
shutdown.target            static
smartcard.target           static
sockets.target             static
sound.target               static
timer-daily.target         static
timer-hourly.target        static
timer-weekly.target        static
timers.target              static
timer-daily.timer          disabled
timer-hourly.timer         disabled
timer-weekly.timer         disabled

So after

$ rm ~/.config/systemd/user/basic.target.wants/timer-*

and

$ systemctl --user enable timer-weekly.timer
$ systemctl --user enable timer-daily.timer
$ systemctl --user enable timer-hourly.timer

I got the timers enabled

 $ systemctl --user list-unit-files |grep timer
timer-daily.target         static  
timer-hourly.target        static  
timer-weekly.target        static  
timers.target              static  
timer-daily.timer          enabled 
timer-hourly.timer         enabled 
timer-weekly.timer         enabled

Great how-to is at https://blog.higgsboson.tk/2013/06/09/use-systemd-as-a-cron-replacement/

systemd timer daily at specific time

I had to change the daily timers time of execution, I wanted it to start at 8am so had to change ~/.config/systemd/user/timer-daily.timer from monotonic to realtime.

[Unit]
Description=Daily Timer

[Timer]
# OnBootSec=10min
# OnUnitActiveSec=1d
# Daily at 8am
OnCalendar=*-*-* 08:00:00
Persistent=True
Unit=timer-daily.target

[Install]
WantedBy=basic.target

Next daemon-reload

$ systemctl --user daemon-reload

And voila:

$ systemctl --user list-timers
NEXT                         LEFT        LAST                         PASSED        UNIT               ACTIVATES
Sun 2015-02-15 09:47:17 CET  18min left  Sun 2015-02-15 08:47:17 CET  41min ago     timer-hourly.timer timer-hourly.target
Mon 2015-02-16 08:00:00 CET  22h left    Sun 2015-02-15 09:28:14 CET  25s ago       timer-daily.timer  timer-daily.target
Fri 2015-02-20 10:21:17 CET  5 days left Fri 2015-02-13 10:21:17 CET  1 day 23h ago timer-weekly.timer timer-weekly.target

For more about systemd.timer check http://www.freedesktop.org/software/systemd/man/systemd.timer.html

logrotate error: stat of /var/log/xferlog failed

In Arch Linux the logrotate service was failing:

user@host# systemctl start logrotate.service 
Job for logrotate.service failed. See "systemctl status logrotate.service" and "journalctl -xe" for details.

So I ran it by hand to debug:

user@host# logrotate /etc/logrotate.conf

And the following error appeared:

logrotate error: stat of /var/log/xferlog failed

I fired up a grep for xferlog in the /etc directory:

user@host:/etc# grep -r xferlog *
logrotate.d/proftpd:/var/log/xferlog

Solution was commenting the xferlog rule in logrotate.d/proftpd. I don’t need the transfer log.