Caveat: I am a Unix novice. There may be better ways to do this, but this worked for me.
Show system date and time in the default format:
$ date
Thu Jun 27 21:23:36 CDT 2013
Show system date and time in yymmdd_hhmmss format (two digit year):
$ date "+%y%m%d_%H%M%S"
130627_212355
Show system date and time in yyyymmdd_hhmmss format (four digit year):
$ date "+%Y%m%d_%H%M%S"
20130627_212416
Save the system date and time in yyyymmdd_hhmmss format to a variable, then show it:
$ var="$(date '+%Y%m%d_%H%M%S')"
$ echo datetime is $var
datetime is 20130627_212437
My requirements: Schedule a SAS program (pd.sas) to run at 4am on June 28th. Send the SAS log to a file whose name includes the system date and time so we can archive the logs.
Step 1: Create a (script) file called go
#!/bin/bashStep 2: Execute a (script) file called go
ts="$(date '+%Y%m%d_%H%M%S')"
echo "sas pd.sas -log pd_$ts.log" | at 0400 Jun 28
$ . go