btrfs.timer runs, but not btrfs.service

I see this from my logs:


> journalctl -u btrfs-scrub.timer | grep 'Started Scrub btrfs filesystem, verify block checksums.' | wc -l
146

> journalctl -u btrfs-scrub.service
-- No entries --

What’s going on here? If I manually run the command invoked by btrfs-scrub.service, I see this on standard out/error:


> sudo /usr/share/btrfsmaintenance/btrfs-scrub.sh
Running scrub on /

Scrub device /dev/nvme0n1p4 (id 1) done
Scrub started:    Sat Sep 24 14:14:33 2022
Status:           finished
Duration:         0:01:53
Total to scrub:   43.07GiB
Rate:             308.68MiB/s
Error summary:    no errors found
flock: getting lock took 0.000003 seconds
flock: executing btrfs

Shouldn’t I see similar journal messages? Or is there an error in the package service file?


> cat /usr/lib/systemd/system/btrfs-scrub.service

[Unit]
Description=Scrub btrfs filesystem, verify block checksums
Documentation=man:fstrim
After=fstrim.service btrfs-trim.service

[Service]
Type=simple
ExecStart=/usr/share/btrfsmaintenance/btrfs-scrub.sh
IOSchedulingClass=idle
CPUSchedulingPolicy=idle

Thanks,

Gene

P.S. Can someone please edit the header line and change it to btrfs-scrub.timer and btrfs-scrub.service?

Thanks
Gene

By default the btrfs-scrub.timer is set to run monthly and that’s what I see in my logs (for me btrfs-scrub.sh runs just after Midnight on the first of the month).

Running in a konsole:

**erlangen:~ #** /usr/share/btrfsmaintenance/btrfs-scrub.sh 
Running scrub on / 

Scrub device /dev/nvme0n1p2 (id 1) done 
Scrub started:    Sun Sep 25 04:34:18 2022 
Status:           finished 
Duration:         0:02:31 
Total to scrub:   480.07GiB 
Rate:             3.09GiB/s 
Error summary:    no errors found 
flock: getting lock took 0.000003 seconds 
flock: executing btrfs 
**erlangen:~ #**
**erlangen:~ #** journalctl -b -g BTRFS 
Sep 25 04:19:25 erlangen kernel: BTRFS info (device sda1): using free space tree 
Sep 25 04:19:25 erlangen kernel: BTRFS info (device sda1): has skinny extents 
Sep 25 04:34:18 erlangen kernel: BTRFS info (device nvme0n1p2): scrub: started on devid 1 
Sep 25 04:36:49 erlangen kernel: BTRFS info (device nvme0n1p2): scrub: finished on devid 1 with status: 0 
**erlangen:~ #**

Running the script as the service:

**erlangen:~ #** journalctl -b -u btrfs-scrub.service  
Sep 25 04:41:56 erlangen systemd[1]: Started Scrub btrfs filesystem, verify block checksums. 
Sep 25 04:41:56 erlangen btrfs-scrub.sh[12239]: Running scrub on / 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Scrub device /dev/nvme0n1p2 (id 1) done 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Scrub started:    Sun Sep 25 04:41:56 2022 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Status:           finished 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Duration:         0:02:29 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Total to scrub:   480.07GiB 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Rate:             3.13GiB/s 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Error summary:    no errors found 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: flock: getting lock took 0.000001 seconds 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: flock: executing btrfs 
Sep 25 04:44:25 erlangen systemd[1]: btrfs-scrub.service: Deactivated successfully. 
Sep 25 04:44:25 erlangen systemd[1]: btrfs-scrub.service: Consumed 36.742s CPU time. 
**erlangen:~ #**

@karlmistelberger: How did you manually run “the script as the service?” I didn’t think you could manually run a service that is triggered by a timer.

Thanks,
Gene

Running the script as the service:

**erlangen:~ #** **systemctl start btrfs-scrub.service**  
**erlangen:~ #** **systemctl status btrfs-scrub.service**  
**●** btrfs-scrub.service - Scrub btrfs filesystem, verify block checksums 
     Loaded: loaded (/usr/lib/systemd/system/btrfs-scrub.service; static) 
     Active: **active (running)** since Sun 2022-09-25 04:41:56 CEST; 9s ago 
TriggeredBy: **●** btrfs-scrub.timer 
       Docs: man:fstrim 
   Main PID: 12231 (btrfs-scrub.sh) 
      Tasks: 8 (limit: 4915) 
        CPU: 1.994s 
     CGroup: /system.slice/btrfs-scrub.service 
             ├─12231 /bin/bash /usr/share/btrfsmaintenance/btrfs-scrub.sh
             ├─12236 /bin/bash /usr/share/btrfsmaintenance/btrfs-scrub.sh
             ├─12237 /bin/bash /usr/share/btrfsmaintenance/btrfs-scrub.sh
             ├─12239 cat
             ├─12244 /usr/bin/flock --verbose /run/btrfs-maintenance-running.0e58bbe5-eff7-4884-bb5d-a0aac3d8a344 btrfs scrub start -Bd /
             └─12245 btrfs scrub start -Bd /

Sep 25 04:41:56 erlangen systemd[1]: Started Scrub btrfs filesystem, verify block checksums. 
Sep 25 04:41:56 erlangen btrfs-scrub.sh[12239]: Running scrub on / 
**erlangen:~ #**
**erlangen:~ #** journalctl -b -u btrfs-scrub.service  
Sep 25 04:41:56 erlangen systemd[1]: Started Scrub btrfs filesystem, verify block checksums. 
Sep 25 04:41:56 erlangen btrfs-scrub.sh[12239]: Running scrub on / 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Scrub device /dev/nvme0n1p2 (id 1) done 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Scrub started:    Sun Sep 25 04:41:56 2022 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Status:           finished 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Duration:         0:02:29 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Total to scrub:   480.07GiB 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Rate:             3.13GiB/s 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: Error summary:    no errors found 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: flock: getting lock took 0.000001 seconds 
Sep 25 04:44:25 erlangen btrfs-scrub.sh[12239]: flock: executing btrfs 
Sep 25 04:44:25 erlangen systemd[1]: btrfs-scrub.service: Deactivated successfully. 
Sep 25 04:44:25 erlangen systemd[1]: btrfs-scrub.service: Consumed 36.742s CPU time. 
**erlangen:~ #**

Show output of

systemctl cat btrfs-scrub.timer
systemctl --all list-timers btrfs-scrub.timer | cat
systemctl status btrfs-scrub.timer
systemctl status btrfs-scrub.service

Thanks for all the input. After following the various suggestions, I realized that my journals only go back 3 weeks, and the last time btrfs-scrub.service ran was 3.5 weeks ago. Years ago when I ran Fedora, I sized them to keep over a month of logs. Apparently, I need to resize them. :slight_smile:

Thanks again,
Gene