#! /bin/sh # Question 4: # Modify your answer to question 3 so that the lockfile will be # /var/lock/subsys/basename of script.lock if the user executing it is # root, /tmp/basename of script.lock otherwise. prog=$(basename $0) uid_num=$(id -u) lockfile="/tmp/${prog}.lock" [ "$uid_num" -eq 0 ] && lockfile=/var/lock/subsys/${prog}.lock if [ -e "$lockfile" ] then echo "lockfile exists" exit 1 else echo "No existing lockfile" fi # just to help in testing: sleep 60