forked from dirakx1/Bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrontab
17 lines (14 loc) · 1.09 KB
/
crontab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0 1 * * * /home/user/postgres_backup/pg_backup.sh
0 1 * * * pg_dumpall |gzip > /home/user/backups/database/allbackup.gzip
0 1 * * * pg_dump db |gzip > /home/user/backups/database/dbname.gz
0 1 * * * pg_dump db |gzip > /home/user/backups/database/dbname-$(date \%d-\%m-\%Y).gz
0 10 * * * pg_dump db |gzip > /home/user/backups/database/dbname.gz
0 10 * * * pg_dump db |gzip > /home/user/backups/database/dbname-$(date \%d-\%m-\%Y).gz
0 2 * * * find /home/user/backups/ -mtime +15 -exec rm {} \;
## Examples with minutes and x seconds with sleep
*/5 * * * * sleep 45; ls /file/*.zip |wc -l > /home/file2.csv
*/5 * * * * find /file3/ -maxdepth 1 -iname "*.zip" |wc -l > file4.csv
*/4 * * * * sleep 10; find /file5/ -maxdepth 1 -iname "*.zip" |wc -l > file10.csv
*/3 * * * * ls -1 /files/temp | grep -i ".pdf$" | wc -l > files.csv
## looking in pasth 3 months
*/9 * * * * find others/$(date --date='-3 month' +%Y'/'%m) others/$(date --date='-2 month' +%Y'/'%m) others/$(date --date='-1 month' +%Y'/'%m) others/$(date +%Y'/'%m) -maxdepth 1 -type f -name 'example_*' -mtime -90| wc -l > results.csv