I have a cron entry to deploy a website portal from a staging server to a series of production servers on a weekly basis.
On occasion, a random office worker who knows nothing about Linux let alone cron, will be tasked to update news picks on the staging server and then run a manual deployment to the production servers. So I threw together a quick PHP/JQuery script that will take the date and time chosen and insert a properly-formatted line into cron.
The trouble I'm having is finding a way to clean out the old one-run cron jobs. Rather than having the sys admin go in once in a while to clean out those old jobs, I'd like to have it deleted at the end of the run. It will take nearly an hour for the deployment to complete, so comparing the minutes passed will be enough.
What I want to do is using a bash script, read in a crontab line, find all lines with specific numbers for the date/time (no '*', ranges, multiples or '*/n'), and compare them to the current date. If in the past, delete the line.
Note there are lines that are comments or variable declarations, as well as the weekly deployment.
Any ideas?
Thanks,
Andrew
---------- Post updated at 01:04 PM ---------- Previous update was at 09:47 AM ----------
Nevermind, got it figured out. Bit of a hack but...
If anyone has a shorter, cleaner solution, I'd appreciate seeing your example code.
The trouble I'm having is finding a way to clean out the old one-run cron jobs.
I don't quite get it: if you want to run a job exactly once, why do you (mis-)use cron instead of using at? The effort is the same, the format is even easier and you don't need any crontab-gymnastics afterwards.
I have multiple jobs and each job dependent on other job.
Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE.
I need an help how to start.
Attaching the JOB dependency... (3 Replies)
Hi all,
I have developed a shell script where I am executing datastage jobs.This script will be further placed in enterprise scheduler to trigger it at particulat time.
I have around 300 jobs , I am passing jobnames to script as a paramere. So is it possible I can trigger all jobs from one... (3 Replies)
Dear all,
I have to create a shell script which will run the job during weekday/weekend in following manner: -
There are 3 jobs
JB_1
JB_2
JB_3
These jobs changes its flag to "COMPLETED" in below 2 ways
1. These 3 jobs which runs after the completion of previous one i.e JB_1 runs and... (5 Replies)
There are two jobs in Solaris , Cron and at jobs..
I know how to disable or enable cron jobs.
How can I enable at jobs and disable it.
Kindly help.
Rj (2 Replies)
Hi
I want to have a list of hung jobs in crontab .
e.g
The below output gives a list of hung jobs including the running one.
"
USER1] ps -ef | grep 22345
root 22345 1 0 Nov 10 ? 0:09 /usr/sbin/cron
user2 1061 22345 0 Nov 11 ? 0:00 sh -c /u01/user2s/b7111/movecsv.ksh
oracle 20456 29535... (2 Replies)
Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day.
Thats because:
The script itself pulls data (textfiles) from a... (3 Replies)
Hi Everyone,
I have written a korn shell script to shutdown my documentum docbase server and to restart it automatically on a weekly basis. My script is,
When i execute this script manually, i was able to execute it successfully without any issues. I have scheduled this script in cronjob... (1 Reply)
i am new for cronjobs
can someone please tell me what logic is behind these RED Numbers and stars below?
--> crontab -l
00 1 * * * /home/scripts/TarprodContent > /tmp/MprodBkup.log 2>&1
00 1 * * * /home/scripts/TarTprodContent > /tmp/TprodBkup.log 2>&1
00 1 * * *... (5 Replies)
I need to monitor my cron jobs with another unix machine since occasionally the cron will go down on the main server but there are no errors. Can anyone help with a script to write to use the cron on the back up machine to monitor the main server?
I am using SCO and the cron jobs have been... (3 Replies)