Listing 2
1: #
2: # Template driver script for background job
3: #
4:
5: debug=Y # to support testing
6:
7: AppId=report # AppId is short description of application
8: Ltmp=/tmp # Work/Log area for the app, publicly writeable
9: UseLock=Y # Y to use lockfiles, N not to
10:
11: [ $UseLock = Y ] && LOCKFILE=$Ltmp/$AppId.LOCK # Name of lockfile
12:
13: echo # Announce the nature of the application
14: echo (Name of report)
15: echo
16:
17: if [ $UseLock = Y -a -f $LOCKFILE ]; then # check for lock file
18: echo "\nSorry, a related report is running. Please try again later."
19: exit 1
20: fi
21:
22: if [ $UseLock = Y ]; then # Prevent zombie lock file if
23: trap "rm $LOCKFILE; exit 1" 1 2 3 9 14 15 # user interrupts this script
24: touch $LOCKFILE # Create the lockfile
25: fi
26:
27: if [ $debug = Y ]
28: then # If debugging, create output file
29: outlog=$AppId.out # in the current directory
30: else
31: outlog=/Ltmp/$AppId.log # else create in the standard place
32: fi
33:
34: bgrun.sh $outlog <<END
35: # *** insert command here ***
36: [ $UseLock = Y ] && rm $LOCKFILE
37: END
38:
39: # alternate form, if a script file has been created as $script:
40: # bgrun.sh $outlog <$script
41:
42: echo "This process is now running in the background."
43:
44: # Give user additional information about output here, if anything to tell.
|