Jason Todd Slack-Moehrle wrote:
Hi All,
I need to write a script that I will manually start (or a cron job in future) but I need it to do a number of things in order one after another. How do i do that so everything gets dont as the steps depend on each other.
Example:
cd /system_backups/
CD = $(date +%Y-%m-%d)
if ! tar cvf apache-conf.tar /etc/httpd/conf/* && gzip -v9 apache-conf.tar; then echo "FATAL ERROR 1" exit elif if ! tar cvf apache-data.tar /var/www/* && gzip -v9 apache-data.tar; then echo "FATAL ERROR 2" exit elif if ! tar cvf $CD-system_backup.tar apache-*.tar.gz && gzip -v9 $CD-system_backup.tar; then echo "FATAL ERR 3" exit elif scp $CD-system_backup.tar.gz user@10.0.0.1:/.
if this is run in a cronjob, any output will be mailed to the user who owns the cronjob. this user's email can be aliased via /etc/aliases to another account if needed.