06-27-2017 05:16 AM
Look at the conditional operators in UNIX shells:
command1 && command2
means that command2 will only be run if command1 succeeds
command1 && command2 || command3
if command1 succeeds, run command2, else run command3
for loop structures in UNIX shells, see https://www.tutorialspoint.com/unix/unix-shell-loops.htm. You'll also find lots of other information for shell scripoting on that website.
07-03-2017 05:58 AM - edited 07-03-2017 06:04 AM
Thank you for you replies,really helpful. In the UNIX Script. create a loop to test the sas program is fail or success. If Fail sleep for a minute to check error. Script will rerun until success then go to next sas progran.
f=sasprogram for f in saslist do sas sasdirectory/$f -log /sas_log/$f.$date.log until [ $? -eq 0 ]; do echo "Processing $f: job fail...\n" echo "Please see error details" /sas_log/$f.$date.log sleep 60 *1 minute sas $sas_dir/$f -log $sas_log/$f.$dateparm.log done "Processing $f: job success...\n" done exit 0
07-03-2017 08:51 AM
I'd add a failsafe that exits with a non-zero return code after a certain number of repeats, to avoid an infinite loop.