Auto Zip a directory Daily

CaptainBlue0

New Member
Joined
Apr 3, 2020
Messages
1
Reaction score
0
Credits
0
Hello everyone,
Brand New user to linux and so far loving it.
I have a quick question is it possible to make a script to auto zip a directory (and its sub directories) it doesn't matter where it saves so long as it is accessible.

Also on a side note if anyone has some good educational links to learn more about using a linux server and the command line, also in linux scripting that would be very helpful.

Edit: Also Should mention It's a off site server and It's running Ubuntu
 


- Make a file called zipper.sh (name it how you want it).
- Make the file executable
chmod +x zipper.sh

-Open the file with a text editor / IDE and give it the following content
Bash:
#!/bin/bash
zip -r /home/sudochecksum/pictures.zip /home/sudochecksum/Pictures/
-r means recurse into directories
first location is where the zip wil be saved and the second location is the folder to zip.

To automate it you can use a cronjob (Wiki)
Run this command to open the cronjob configuration file
Bash:
crontab -e

An example if you want the command to run every day “At 05:00.”
Code:
0 5 * * * /path/to/zipper.sh
To get some help on generating time for cronjobs checkout this cron generator.
After placing the line into the config file , save it and restart the linux system.
 

Members online


Latest posts

Top