You are not logged in.

#1 2018-06-20 07:45:53

mrlamud
Member
Registered: 2014-09-27
Posts: 104

[Solved] Please advise. How to translate this script to systemd..?

I have this cron job script which also writes output to a log.

#!/bin/sh
LOG=/var/log/trim.log
echo "*** $(date -R) ***" >> $LOG
fstrim -v -a >> $LOG

This is my service unit

[Unit]
Description=Weekly activate trim as per mount option in fstab.
ConditionACPower=true

[Service]
Type=oneshot
ExecStart=fstrim -v -a

[Install]
WantedBy=default.target

What I'm missing is how to write the output to its log.

Last edited by mrlamud (2018-06-20 08:37:50)

Offline

#2 2018-06-20 08:08:52

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [Solved] Please advise. How to translate this script to systemd..?

Why not use the existing fstrim.timer?

Other than that, systemd logs when timers starts and the process output, so you could rely on that instead of writing the log yourself.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2018-06-20 08:36:56

mrlamud
Member
Registered: 2014-09-27
Posts: 104

Re: [Solved] Please advise. How to translate this script to systemd..?

How stupid I'm!!!

Thanks for point this out.

Offline

Board footer

Powered by FluxBB