- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Can cronjob script change the timing for itsel...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 07:20 PM
08-20-2001 07:20 PM
Can cronjob script change the timing for itself to be executed?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 07:27 PM
08-20-2001 07:27 PM
Re: Can cronjob script change the timing for itself to be executed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 07:59 PM
08-20-2001 07:59 PM
Re: Can cronjob script change the timing for itself to be executed?
The mechanism I've used for this in the past is a file semaphore. Have your initial job touch a file like /tmp/notyet. Have your cron job test for the existence of /tmp/notyet. If /tmp/notyet exists, sleep for a while then check again. Once the file /tmp/notyet no longer exists, your script can proceed.
All the best,
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 08:09 PM
08-20-2001 08:09 PM
Re: Can cronjob script change the timing for itself to be executed?
With a little bit of complication I think you can do it.
There should be two files
1) one cron wrapper - cron_wrapper
2) Your original script - your_script
Now your cron_wrapper will contain the following. This is only a rough draft. The original script will be more complicated as you need to take care of Hours, minutes etc.,
ps -ef |grep -v grep |grep your process
if [ $? = 0 ] #the Process is running
then
HOUR=`date +%H`
MYHOUR=`echo "$HOUR + 1 " |bc` #this will schedule the job one hour later.
echo "* $MYHOUR * * * your_path/cron_wrapper" >> /tmp/mycron$$
crontab /tmp/mycron$$ > /dev/null 2>&1
rm /tmp/mycron$$
echo "Rescheduled to $MYHOUR" >> $your_log
exit
else
your_patch/your_script >> $your_log 2>&1
crontab -r
fi
Initially you need to put
"* $MYHOUR * * * your_path/cron_wrapper"
in your crontab. Depending on whether the process is running or not, your cron_wrapper will take care of it.
It will be much more complicated if you want to introduce minutes also. Because you need to check to see if your MY_HOUR or MY_MIN will become greater than 60.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 10:26 PM
08-20-2001 10:26 PM
Re: Can cronjob script change the timing for itself to be executed?
The method we use to prevent multiple instances of a script from running when scheduled through cron, is to configure cron to run only once and at the end of the script schedule the cron again to run only once. In this way we can be sure that there will be no two instances of the script running simultaneously.
This has worked for us...
...BPK...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 01:02 PM
08-21-2001 01:02 PM
Re: Can cronjob script change the timing for itself to be executed?
#!/usr/bin/sh
###############################################################################################################
## Start Arc License Mangager
###############################################################################################################
echo ""
echo ""
echo "#########################################################################"
echo " Start Arc License Manager"
echo "#########################################################################"
check_arc_license=`check_arc_license`
if [ $? -gt 0 ]
then
arc_license_started=.false.
count1=1
while [ "X$arc_license_started" = "X.false." ]
do
echo "Trying to start the Arc/Info License Manager $count1 !" | tee -a $logfile
start_arc_license=`su arcadmin -c start_arc_license >/dev/null 2>&1 &`
echo "Waiting 5 Seconds for the Arc/Info License Manager to Start!" | tee -a $logfile
dotcount=1
while [ $dotcount -le 5 ]
do
print -n .
sleep 1
((dotcount=$dotcount+1))
done
print -n " --->"
check_arc_license=`check_arc_license`
if [ $? = 0 ]
then
arc_license_started=.true.
echo "Arc License Manager STARTED ! :)" | tee -a $logfile
echo ""
echo ""
else
if [ $count1 -ge 5 ]
then
echo "hmm.... :( -- Could not start Arc License Manager after $count1 Tries !" | tee -a $logfile
echo $start_arc_license | tee -a $logfile
echo "I Quit :( -- Aborting: `basename $0`: `date`" | tee -a $logfile
exit 1
fi
sleep 5
((count1=$count1+1))
fi
done
else
echo "hmm.. :) Arc License Manager already running on node: `hostname`" | tee -a $logfile
fi
echo " " >> $logfile
Here's the check_arc_license script. It doesn't have to be seperate, but I did it this way so I could use it over :)
#!/usr/bin/sh
host=`hostname`
check_node=`lmstatus | grep "$host: license server UP"`
error_trap=$?
if [ $? = 0 ] && [ $error_trap = 0 ]
then
exit 0
else
exit 1
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2001 08:42 AM
08-22-2001 08:42 AM