Assist with easy cron job


Recommended Posts

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

Link to comment
  • 2 weeks later...

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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.