You are not logged in.
Hi,
I have two executables in /usr/local/bin, one script which. among other things, runs the other application. I have a working timer/service combo for this but for some reason I can only get it to run if I add a third script which then runs the application/script combo. So instead of having the timer run A.sh which also starts B I had to add C.sh which runs A.sh and B. All three can be run from the command line without problems. The error I get in the systemd journal is:
Nov 30 06:30:28 thinkpad1 systemd[9533]: btrfs-scrub.service: Failed at step EXEC spawning /usr/local/bin/btrfs-scub: N
I am trying to learn systemd timers so I wonder what the reason may be for needing the third script to run the other two when run by the timer/service?
Update: The problem was a typo in the timer.
Last edited by cdysthe (2016-11-30 17:43:28)
Offline
Post the contents of your scripts and timer/service files, we can't help without them.
Last edited by Slithery (2016-11-30 14:44:55)
Offline
Hi,
Here's what I've got:
/etc/systemd/system/btrfs-scrub.timer
[Unit]
Description=BTRFS Scrub
[Timer]
OnCalendar=*-*-* 2:40:00
Persistent=true
[Install]
WantedBy=timers.target
/etc/systemd/system/btrfs.scrub.service
[Unit]
Description=BTRFS Scrub
[Service]
ExecStart=/usr/local/bin/scrub.sh
Type=simple
/usr/local/bin scrub.sh
#!/bin/sh
/usr/local/bin/btrfs-scrub
/usr/local/bin/btrfs-scrub
#!/bin/sh
# By Marc MERLIN <marc_soft@merlins.org> 2014/03/20
# License: Apache-2.0
which btrfs >/dev/null || exit 0
export PATH=/usr/local/bin:/sbin:$PATH
# bash shortcut for `basename $0`
PROG=${0##*/}
lock=/var/run/$PROG
# shlock (from inn) does the right thing and grabs a lock for a dead process
# (it checks the PID in the lock file and if it's not there, it
# updates the PID with the value given to -p)
# You can replace this with another lock program if you prefer or even remove
# the lock.
if ! shlock -p $$ -f $lock; then
echo "$lock held, quitting" >&2
exit
fi
if which on_ac_power >/dev/null 2>&1; then
ON_BATTERY=0
on_ac_power >/dev/null 2>&1 || ON_BATTERY=$?
if [ "$ON_BATTERY" -eq 1 ]; then
exit 0
fi
fi
FILTER='(^Dumping|balancing, usage)'
test -n "$DEVS" || DEVS=$(grep '\<btrfs\>' /proc/mounts | awk '{ print $1 }' | sort -u)
for btrfs in $DEVS
do
tail -n 0 -f /var/log/scrub.log | grep "BTRFS: " | grep -Ev '(disk space caching is enabled|unlinked .* orphans|turning on discard|device label .* devid .* transid|enabling SSD mode|BTRFS: has skinny extents|BTRFS: device label)' &
mountpoint="$(grep "$btrfs" /proc/mounts | awk '{ print $2 }' | sort | head -1)"
logger -s "Quick Metadata and Data Balance of $mountpoint ($btrfs)" >&2
# Even in 4.3 kernels, you can still get in places where balance
# won't work (no place left, until you run a -m0 one first)
btrfs balance start -musage=0 -v $mountpoint 2>&1 | grep -Ev "$FILTER"
btrfs balance start -musage=20 -v $mountpoint 2>&1 | grep -Ev "$FILTER"
# After metadata, let's do data:
btrfs balance start -dusage=0 -v $mountpoint 2>&1 | grep -Ev "$FILTER"
btrfs balance start -dusage=20 -v $mountpoint 2>&1 | grep -Ev "$FILTER"
# And now we do scrub. Note that scrub can fail with "no space left
# on device" if you're very out of balance.
logger -s "Starting scrub of $mountpoint" >&2
echo btrfs scrub start -Bd $mountpoint
ionice -c 3 nice -10 btrfs scrub start -Bd $mountpoint
pkill -f 'tail -n 0 -f /var/log/scrub.log'
logger "Ended scrub of $mountpoint" >&2
done
rm $lock
/usr/local/bin/btrfs-scrub
is running the application
/usr/local/bin/shlock (From Inn)
. If I try to run
/usr/local/bin/btrfs-scrub
directly from the timer it fails. If I use
/usr/local/bin/scrub.sh
it runs as it should.
I have used this setup on other distros so I thought I could use it on my new Arch install as well. This is the first time I try to run it with a systemd timer.
Last edited by cdysthe (2016-11-30 15:15:46)
Offline
Nov 30 06:30:28 thinkpad1 systemd[9533]: btrfs-scrub.service: Failed at step EXEC spawning /usr/local/bin/btrfs-scub: N
/usr/local/bin/btrfs-scub? Sounds like you may have typoed the script name.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Nov 30 06:30:28 thinkpad1 systemd[9533]: btrfs-scrub.service: Failed at step EXEC spawning /usr/local/bin/btrfs-scub: N
/usr/local/bin/btrfs-scub? Sounds like you may have typoed the script name.
I bow my head in shame. Typo! No wonder the script worked. Thanks!
Offline
Next time, be sure to paste the contents of the timer in the non-working condition, that too can help detect the typo variety of probem.
Please edit the first post and mark the thread title as solved.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Next time, read (and post) the whole error message -- after the "N" you would have seen "o such file or directory"
Offline