Thursday, June 29, 2017

How to auto zip folder(s) in linux from command line for scheduling tasks


This guide will show you how to zip folder(s) in linux with command line.


For Exa: If you have a folder in linux on a path say:-

/home/John/Maindata/Imp_data

and you want to zip "Imp_data" folder

Below given are the steps and commands to zip folder(s) in linux with command line.

Open text Editor (Gedit / Leadpad)

Write the below given commands (copy-paste the command and save it with file extension "filename.sh")

____________________________________________________

#!/bin/bash
echo "processing......Please wait !!"

zip -r Imp_data.zip "/home/John/Maindata/Imp_data"

echo "Completed"
_____________________________________________________

Then go to terminal and write the following command

> chmod +x "filename.sh"  (press enter)
>

This will make that file executable. So now you can run this file for automated zip process.

# Now you can run this file manually or use this for scheduled tasks.


This will create a zip file on the same location like:-

home/John/Maindata/Imp_data.zip

No comments:

Post a Comment