Changeset 14375
- Timestamp:
- 01/11/08 14:39:14 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/MidCOM_2_8/midcom.core/support/midcom_services_cron.sh
r6009 r14375 17 17 # like "lynx -auth=username:password" for HTTP basic-auth 18 18 LYNX="lynx" 19 STAT="stat -c %Z" # how to get file timestamp 20 DATE="date +%s" # how to get system timestamp 21 LIFETIME=3600 # Max pidfile age in seconds before it's considered stale 19 22 20 if [ "$1" == "" ]; then 23 if [ "$1" == "" ] 24 then 21 25 URL_SUFFIX="" 22 26 PIDFILE="/var/run/midcom_services_cron_everymin.pid" … … 28 32 fi 29 33 30 # TODO: figure out a locking mechanism that ensures only one instance 31 # is running at a time, without missing any valid runs 34 function check_pidfile 35 { 36 if [ -f $1 ] 37 then 38 MODIFIED=`$STAT $1` 39 NOW=`$DATE` 40 AGE=`expr $NOW - $MODIFIED` 41 #echo "MODIFIED=$MODIFIED NOW=$NOW AGE=$AGE LIFETIME=$LIFETIME" 42 if [ "$AGE" -lt "$LIFETIME" ] 43 then 44 return 1 45 fi 46 echo "Lock $1 is stale, removing" 47 # PONDER: Should we kill the process ??, the line below should do the trick 48 # kill -9 `cat $1` 49 rm -f $1 50 return 0 51 fi 52 return 0 53 } 32 54 33 55 # Make sure we only have one copy of the type running at a given time 34 test -f $PIDFILE && exit 1 56 check_pidfile $PIDFILE 57 PIDSTAT=$? 58 if [ "$PIDSTAT" != "0" ] 59 then 60 exit 1 61 fi 35 62 echo $$ > $PIDFILE 36 63 # Wait untill everymin script has completed if it's running 37 if [ "$PIDFILE2" != "" ]; then 38 if [ -f $PIDFILE2 ]; then 39 while [ -f $PIDFILE2 ]; do 40 sleep 10 41 done 42 fi 64 if [ "$PIDFILE2" != "" ] 65 then 66 check_pidfile $PIDFILE2 67 PIDSTAT2=$? 68 while [ "$PIDSTAT2" != "0" ] 69 do 70 sleep 10 71 check_pidfile $PIDFILE2 72 PIDSTAT2=$? 73 done 43 74 fi 44 75 45 for SITE in $SITES; do 46 if [ `expr match "$SITE" 'https*'` -eq 0 ]; then 76 for SITE in $SITES 77 do 78 if [ `expr match "$SITE" 'https*'` -eq 0 ] 79 then 47 80 URL="http://$SITE/midcom-exec-midcom/cron.php$URL_SUFFIX" 48 81 else
