Issue
I have a server which is always online, I want during night hours, to run a job on the server that simply copies from /folderA
-> /folderB
.
I would not like to keep my screen on while my rsync is performing the job.
Is there any way of using this command:
rsync -avhW --no-compress --progress folderA/. folderB/
while I turn off my SSH station (laptop)?
Thanks
Solution
You are looking to setup a cron job. Cron jobs are tasks that run automatically on a schedule. To setup your rsync
job:
- Login to your server via SSH
- Run
crontab -e
. This will open a file in the server's default text editor. Typically, this file will have some comments with details on how to add a job - To the last line of the file, add
30 11 * * * rsync -avhW --no-compress --progress folderA/. folderB/
. This will run the job at 11:30PM every day. For changing the scheduled time, see the link above. - Save and exit
You can now logout from the server and the job will run every day at the scheduled time. Since the job is scheduled on the server, your workstation can be off and you do not need to logged into the server. The task will keep running on schedule until you remove the line from the crontab
file.
Answered By - veesar Answer Checked By - Mary Flores (WPSolving Volunteer)