Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run the script at an exact day & time

Status
Not open for further replies.

meetramana

Programmer
Feb 2, 2005
57
US
Hi all,

Is there way that I can run a script at an exact date and time without having to define a cron job.

something that I can run with in a script which watches for the date and time and kicks another script at the specified time.

Thanks
 
man at

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks for your reply

I checked in the at.allow file, and I can not run at command or cronjob.

I just need to write my own script something that watches the time and runs my script.

any other ideas?

Thanks
 
an infinite "while" loop with a "sleep" for a minute, waking up comparing the current time with the "scheduled" time. Calling the "my script" if needed [and exiting] OR continuing with the loop.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
This might work:

Code:
$ cat dtest                           
TIME=133000                           
while true                            
do                                    
        NOW=`date +%H%M%S`            
        if [ "$TIME" = "$NOW" ]       
        then                          
                echo "Now is the Time"
                sleep 2               
        else                          
                sleep 2               
        fi                            
done                                  
[\code]
 
Have a word with your sys admin and persuade them to allow you access to at and cron. Basically, you're trying to circumvent the denial of your access to these functions in any case!!
 
If your sys admin won't let you use at or cron, he/she isn't going to be happy to find a daemon or scripting running around the clock watching the time (chewing up resources)....

That wouldn't fly with me.

explain the situation and you'll both be better off with a cron job.
 
motoslide script worked fine. Thanks

I don't use that daily or weekly or on any regular basis which is why the need for a small script to run at midnight.

They were not happy setting up a cron job for just some unknown days as it is not regular.

however I think I was not chewing up much of the resources as I used sleep for 10 minutes at a time.

Thankyou all for your inputs

Have a Great Day


 
Just a thought, which might be helpful. We use the following technique to achieve a similar outcome. The script is set to run at midnight on a daily or weekly or monthly basis from crontab. One of the first things the script does it to check for the existence of a "User defined" flag file in a specific location (and if necessary owned by a specific username) and if present the script runs normally. If the flag file is missing, then the script exits early with a mail message to the User. (We actually use this in reverse, so that the User can "cancel" the script if the flag file is present, but the principle is the same).

I hope that helps.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top