The most straightforward way to do this would be to have your 2am and 7am tasks coordinate. So for instance, the DB backup script could create a lock file when it executes, and check for the existence of this file when it starts up. If the file exists it could simply exit without doing any work (or sleep for a bit, or whatever you decide) Doing this in a completely task-agnostic way might be possible, but it's going to be trickier and unnecessary in this particular case.
The most straightforward way to do this would be to have your 2am and 7am tasks coordinate. So for instance, the DB backup script could create a lock file when it executes, and check for the existence of this file when it starts up. If the file exists it could simply exit without doing any work (or sleep for a bit, or whatever you decide).
Doing this in a completely task-agnostic way might be possible, but it's going to be trickier and unnecessary in this particular case.
A lock file would have to be managed (if backup script crashes and lock file not cleaned up), or perhaps ignored if older than 24 hrs. Better to ask the database if it is being backed up (if that is possible in this case). – jowierun Jun 29 '10 at 10:45.
Assuming you are on a Unix system: The easiest way to do this is create a file and write the cron job's PID to it. If the file can't be created using open(2) with O_CREAT|O_EXCL flags, it already exists, thus the previous job is still running or has crashed without cleaning up. The PID can be used to determine whether the job is still running.In your case, the safest approach is probably for the cron job to die if the PID file is found on startup.
Since you put the perl tag to the question, I suggest to have a look at the File::Pid and Proc::PID::File modules.
You just need something that you can check to see if the first task has finished running, and this check should be done right before the job runs again. I'd implement this with a database (if available) or a registery key or even a text file. So your task would look like this: read job_flag if job_flag == 0 step job_flag = 1 run job step job_flag = 0 else stop job end.
You can do that just using cron. You are going to have to add some logic to your script or code to check if the other one is running or not. A total hack would be to have your script check for the exists of a particular file.
If it does not exist then you should create this file, perform the backup, then remove it. If the file does exist, do nothing. That is a hack and only really works because your jobs are spaced so far apart.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.