Skip to content

Commit

Permalink
Fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthDhavan04 committed Jul 22, 2024
1 parent 1b53ab2 commit 374ef76
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
Binary file added Day 2/Issue 9/Parth/Shell Script/ss/image (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day 2/Issue 9/Parth/Shell Script/ss/image (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day 2/Issue 9/Parth/Shell Script/ss/image (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day 2/Issue 9/Parth/Shell Script/ss/image (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day 2/Issue 9/Parth/Shell Script/ss/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Day 2/Issue 9/Parth/Shell Script/task1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

read -e -p "Log Directory: " log_directory
read -e -p "File Extension: " extension
read -e -p "Backup Directory: " backup_directory

# Add the cron job to run every two days at midnight
(crontab -l 2>/dev/null; echo "0 0 */2 * * /bin/bash $(realpath "$0")") | crontab -

echo "Cron job added"

tar czf archive.tar.gz $(find "$log_directory" -name "*.$extension")
mv archive.tar.gz "$backup_directory"/$(date +%F).tar.gz
rm $(find "$log_directory" -name "*.$extension")

exit 0

0 comments on commit 374ef76

Please sign in to comment.