PeteAsking Posted November 25, 2022 Share Posted November 25, 2022 Hi there, Can anyone assist in making an easy script that will run the following command every 2 months? I would also like it to log its output to a file and overwrite the file every 2 months so i can review it. Command I want to run on the schedule: btrfs filesystem defragment -r -v -clzo /mnt/btrfsprotect Kind regards P Quote Link to comment
PeteAsking Posted December 4, 2022 Author Share Posted December 4, 2022 In case anyone needs to know I used user scripts and made this script: #!/bin/bash date > /mnt/btrfsprotect/domains/Defrag.log btrfs fi show /mnt/btrfsprotect >> /mnt/btrfsprotect/domains/Defrag.log btrfs filesystem defragment -r -v -clzo /mnt/btrfsprotect/ >> /mnt/btrfsprotect/domains/Defrag.log btrfs fi show /mnt/btrfsprotect >> /mnt/btrfsprotect/domains/Defrag.log date >> /mnt/btrfsprotect/domains/Defrag.log Works fine on a cron schedule just change schedule to custom and enter: 1 5 1 2,4,6,8,10,12 * for the 2 months thing. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.