step1: create script file
touch script.sh
step2: write all git commands
git add --all
git commit -m"Weekly Backup"
git pull origin master
git push origin master
step3: open text editor to automate git commands
export EDITOR=vi
crontab -e
step4: open text editor to automate git commands
0 3 * * 0 /bin/bash /opt/lampp/htdocs/cloudopsnow/weekly-backup.sh
Automating Database backup
/opt/lampp/bin/mysqldump --opt -Q -h localhost --no-tablespaces -u root --password='Hs?gb?S345' sresc | gzip -9 > /opt/lampp/htdocs/sresc/.bkp/sresc-$(date +%d_%m_%Y).gz
set corn job
0 3 * * 0 /bin/bash /opt/lampp/htdocs/cloudopsnow/weekly-backup.sh
set permission
chmod +x script.sh
OTHER use of corn job
command every day at 3:00 AM
.
0 3 * * * php /bin/bash /opt/lampp/htdocs/motoshare.in artisan optimize:clear
============OR another way================
using./pull.sh
This deletes logs older than 7 days every Sunday at midnight
.
0 0 * * 0 find /bin/bash /opt/lampp/htdocs/motoshare.in/storage/logs -type f -name "*.log" -mtime +7 -delete
Top comments (0)