I've got three SAS programs to run in the background over a weekend. The three programs output information into files of the same names, so I'll need to remove these output files after the first program finishes and before the second program starts, as well as after the second program finishes and before the third program starts. Obviously the simplest way to get around this issue is to alter each of the programs in such a way that the output filenames are different, but that wouldn't help me learn how to use Unix. So this is what I've got so far:
# Begin by running the first SAS program in the background. sas program1.sas & | at 5:00 PM JAN 11 # I'd like to wait until the first program finishes to remove # the output files and run the second program. wait ??? rm file1.sas7bdat file2.sas7bdat file3.sas7bdat file4.sas7bdat file5.sas7bdat sas program2.sas & | at 5:00 PM JAN 12 # And now I repeat. wait ??? rm file1.sas7bdat file2.sas7bdat file3.sas7bdat file4.sas7bdat file5.sas7bdat sas program3.sas & | at 5:00 PM JAN 13
I set each program to run at the same time on consecutive days for two reasons: (1) I know the previous program will finish within 24 hours, and (2) I am assuming the load on the server will be similar at the same time on consecutive days. Ideally I could somehow grab the process ID for the first program and pass it to the first
wait command, and similarly for the second program and
wait command. Any ideas?
I am more interested in a general solution for determining a process ID and passing it to the
wait command than this specific situation.