Sponsored Content
Full Discussion: Cronjob Activation
Top Forums Shell Programming and Scripting Cronjob Activation Post 302165062 by Smiling Dragon on Wednesday 6th of February 2008 05:02:36 PM
Old 02-06-2008
Quote:
Originally Posted by Raynon
Running the script continously means to say that i have to leave a command prompt window always open. Once closed, the process will be ended
Not at all, just move it to the background, no different to all the other daemonised stuff you are running on your system. If it likes to write to STDOUT, redirect this to a log file (or /dev/null if you prefer).
Quote:
Originally Posted by Raynon
and also another disadvantage is that a infinite looping script will eat up alot of resources, wouldn;t it ?
Much as before, no problems here either. Just use sleep at the bottom of the loop to stop it thrashing.
Quote:
Originally Posted by Raynon
So i still think cron is the more practical one.
Your call of course.
Quote:
Originally Posted by Raynon
But i have no idea about anacron or control-m. Can you enlightened me on that ?
Anacron is a slighty more advanced version of cron, may or may not do what you want. Free (I think)
Control-M is a BMC product that manages scheduling at an enterprise level, it supports job dependancies, understands limited resources and works across multiple platforms. Costs a bit.

Google for more info on these
Quote:
Originally Posted by Raynon
Can you give an example of script being re-entrant ?
Reentrant just means that it can be run multiple times at once without going wonky. One example:
Not rentrant:
Code:
#!/bin/sh
/usr/bin/do_some_stuff > /var/log/did_some_stuff.log
do some other things
if grep 'it worked' /var/log/did_some_stuff.log
then
  /usr/sbin/assume_we_are_good_to_go
else
  echo "Argh"
fi

Reentrant:
Code:
#!/bin/sh
/usr/bin/do_some_stuff > /var/log/did_some_stuff.$$.log
do some other things
if grep 'it worked' /var/log/did_some_stuff.$$.log
then
  /usr/sbin/assume_we_are_good_to_go
else
  echo "Argh"
fi
rm /var/log/did_some_stuff.$$.log

The first example could end up reading back the log of a different instance of itself. The second version includes the current process ID in the log file which prevents this happening.

Another, simpler, way is to just look in the process table for another copy of the script, if found exit immediatly.

Quote:
Originally Posted by Raynon
I was thinking if i could make the script check for the process to see if the previous process have been completed, can any experts give me some examples of this ? I am using csh by the way.
(Assuming system V as opposed to bsd)
Code:
#!/bin/csh
set numprocs=`ps -ef | grep -v grep | grep $scriptname | wc -l | awk '{ print $1 }'`
if ($numprocs == 1) then
    # carry on
else
   echo "Another instance is already running, exiting..."
   exit 0
endif

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Wireless ipw2200 activation

hello ! i am trying to activate my wireless network card on my laptop currently running : 2.6.18-1.2869.fc6 , but an error msg appears "ipw2200 device eth1 does not seem to be present, delaying initialization." the same msg also appears at the start up process, when trying to bring up eth1. ... (4 Replies)
Discussion started by: XinU*
4 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Did not receive activation mail

Hi Administrators, I've registered myself yesterday and have been waiting for my account to be activated. I've followed the instructions in the 'See this if you have an account but cannot post ' thread to request for an activation mail to be sent to my other email address, but still did not... (0 Replies)
Discussion started by: pl_cyber
0 Replies

3. Forum Support Area for Unregistered Users & Account Problems

Account Activation Problem

Hi, I got the username and activation code to my email id but when i click on the forum link and enter the activation code and username there then , It displays "We could not activate your account because this web address is not valid. Make sure that you have the entire address from the... (1 Reply)
Discussion started by: MIKU
1 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Activation

can't activate (0 Replies)
Discussion started by: jamalwil7
0 Replies

5. Forum Support Area for Unregistered Users & Account Problems

Please send activation mail..

Hi, I have registered your site and i havent received any activation mail. please send me activation mail. Thanks & Regards, BVIJAY (1 Reply)
Discussion started by: bvijaycom
1 Replies

6. Forum Support Area for Unregistered Users & Account Problems

I need another activation email

Hi neo I registered yesterday,but i don't receive the activation email,can u send again? thanks! (1 Reply)
Discussion started by: swrd
1 Replies

7. Forum Support Area for Unregistered Users & Account Problems

Still waiting for activation email

Hi, I've been waiting for about 2 hours to receive my activation email but it hasn't arrived yet. I followed the 'resend activation information' link so I'm now expecting 2 activation emails, neither has arrived yet. How long do I expect this to take? I've tested my email account from other... (2 Replies)
Discussion started by: cambridge
2 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Activation problems with new account.

I received the email describing how to acivate my new account (I'm using Outlook 2007). I tried clicking the URL given and was told "invalid web address". I tried copying and pasting both URL's - "invalid web address. Lastly, I tried typing in the URL - "invalid web address". There were no spaces... (1 Reply)
Discussion started by: ki6bxp
1 Replies

9. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

10. Forum Support Area for Unregistered Users & Account Problems

Not able to post after activation

Hi... I got my account created and after activation I'm not able to create new posts or start a new thread. Can you help on how to start a new thread? Thanks. (1 Reply)
Discussion started by: Bang3095
1 Replies
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy