0
I have some scripts that do usual stuff like backing up MySql database, gz, tar some files and put them on FTP or sync with some other backup/mirror system. Some scripts are running quite frequently (like twice/thrice per hour). I am sending email with attached log output from commands after completion of job. It is quite a lot of email to keep track of.
I want to send email only when script fails to do something, that is when some command in script fails. How can I accomplish this?
suppose I run a command using
curl
likecurl --upload-file.....
in a script how will I check status?i = curl --upload-file...
thenif [i eq 0]
? – TheVillageIdiot – 2011-06-29T19:43:28.9132Status of last command is saved in variable "$?", so you can use [ $? -eq 0 ] – bbaja42 – 2011-06-29T19:49:10.147
2
@TheVillageIdiot: Example.
– user1686 – 2011-06-29T20:04:20.690@bbaja42 and @grawity thanks for clearing up the things. I'm accepting @ssapkota's answer. – TheVillageIdiot – 2011-06-30T05:42:51.707