Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 5606  / 2 Years ago, thu, march 10, 2022, 7:59:03

I currently have too many rsync commands that I run on a day to day basis.

Could someone be kind enough to let me know how I can automate these commands?

I am new to Linux so a little bit of explanation might be needed.


More From » rsync

 Answers
6

So first save the following in a file named rsynccommands.sh



#! /bin/bash

echo "starting all"
rsync-command-1
echo "completed 1"
rsync-command-2
echo "completed 2, starting 3"
rsync-command-3
echo "completed 3, starting 4"
rsync-command-4
echo "completed 4, starting 5"
rsync-command-5
echo "completed 5, completed all."


That is a bash script.



Make the script executable:



chmod + x /hom/USER/path/to/rsynccommands.sh


Then run the command crontab -e and copy/paste the following:



30 13 * * * /home/USER/path/to/rsynccommands.sh >/dev/null 2>&1


That will run the script every day at 1:30pm, the 30 being 30 mins past and the 13 being 1pm. The stars mean every day, month and year.


[#23907] Friday, March 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
suitman

Total Points: 487
Total Questions: 105
Total Answers: 98

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
;