[SOLVED] Run A Missed or Failed Cron Job Using a Past Date Time Stamp
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
Let us suppose a job named "calculate-credits.sh" is supposed to be run at these time intervals:
1st Run at 6 AM
2nd Run at 8 AM
3rd Run at 10 AM
However, due to a system unavailability issue from 9 AM through 1 PM the 3rd job was not fired. We identify this issue at 2 PM. Now, we need to run the job manually. However, we want to run it with the past date-time stamp, i.e. 10 AM in this case. How can we do that? System Used is: CentOS 6
As michaelk said, without seeing the script we can't say. But if you want to run it with a SYSTEM time-stamp of 10 AM...you should know you cannot. Cron will put the time stamp the job runs into the cron log, so unless you manually edit that file to change things, you're out of luck. If you run it manually, anything that it updates (files/directories/databases), will ALSO have the correct time, and have to be manually adjusted, if it can be. Mirroring system logs? Gotta change ALL of that manually too.
As an administrator with at least seven years experience, with many 'certifications', it's surprising you don't know these things.
You are right. Despite all those certificates, and experiences I don't know the solution being sought here is impossible.
You know, when I posted this question here. I had this feeling. If you happened to check it out, you would copy/paste your ages old slogan about me: Many years of experiences and certificates.
I kind of got used to it long ago.
But let me tell you, when I was a beginner in the IT field, I used to ask a lot of questions. Silly questions. Impossible ones. And possible too.
It took me sometime to fall into the habit of stop asking questions on forums. I began researching on the Internet. Most of these things would be from Interviews I attended or my friends did. When I concluded that a question like this one was a product of illogical and irrational thought process, I still would have a second thought: Maybe there is something I have not looked at before. Maybe, some other person has done and seen it.
And then I turned to this group of talent pool to see if my conclusion was already valid.
Yes, my conclusion was valid but I wanted to revalidate it by posting here. Gents, you are awesome that you keep my points valid!
Now, if the same interviewer asks the same question again, I will ask him to refer to this post.
There is this command
# touch fileName
that can be used to change different time parameters of a file and we can set a past date and a future date too. You already k ow it.
But to update log files that have recent logs and then we insert past timestamps is not a logical thing to do. Even automatically.
Do you have a thing to ask interviewers who ask such illogical questions and make you look inexperienced?
Without knowing anything about your calculate-credits.sh script or how it uses a time stamp it is impossible for anyone to know how you can do that.
Agreed.
But that was all the detail I got in the question asked by a teammate. I explained thay it was not how updating logs works. We get logs in a chronological order and reversing them in between is not a desirable thing to do.
Besides, running the same job from command line would do the work if it has no time based dependencies such as input data from other sources.
But as you might know, some interviewers would stick to their points and would not tell you their hypothetical solutions.
@TB0NE:
You are right. Despite all those certificates, and experiences I don't know the solution being sought here is impossible.
Which makes me ask: "Why not?", and "It's NOT impossible, why don't you know the solution?"
Quote:
You know, when I posted this question here. I had this feeling. If you happened to check it out, you would copy/paste your ages old slogan about me: Many years of experiences and certificates. I kind of got used to it long ago. But let me tell you, when I was a beginner in the IT field, I used to ask a lot of questions. Silly questions. Impossible ones. And possible too.
It took me sometime to fall into the habit of stop asking questions on forums. I began researching on the Internet. Most of these things would be from Interviews I attended or my friends did. When I concluded that a question like this one was a product of illogical and irrational thought process, I still would have a second thought: Maybe there is something I have not looked at before. Maybe, some other person has done and seen it. And then I turned to this group of talent pool to see if my conclusion was already valid. Yes, my conclusion was valid but I wanted to revalidate it by posting here. Gents, you are awesome that you keep my points valid!
Now, if the same interviewer asks the same question again, I will ask him to refer to this post. There is this command
# touch fileName
that can be used to change different time parameters of a file and we can set a past date and a future date too. You already k ow it.
But to update log files that have recent logs and then we insert past timestamps is not a logical thing to do. Even automatically. Do you have a thing to ask interviewers who ask such illogical questions and make you look inexperienced?
Is there a point to this rant? Yes, I mentioned it, because you KEEP POSTING things like this. For someone with nine years experience, degrees/certifications, etc., the 'touch' command should be obvious. And you DID NOT ask how to do it automatically, did you? You asked how to do it...and you were told issues you'd have to deal with, all depending on your environment. Things that 'interviewers' would ask, like "are you syncing your log files?", etc. Things that someone with 'advanced degrees and certifications', and years of experience should know.
Again, you were told that you'd have to edit the log files. There are even 'automatic' ways to do it, using built-in commands, that you should also know. And before going on about "pasting the old slogan", try looking at your posting history:
Where you claim to have looked things up, and couldn't seem to figure out how to pipe commands, use the lp command, or write a basic script: https://www.linuxquestions.org/quest...le-4175623648/
...etc., etc. You ask VERY basic questions, and claim to have 'degrees and certifications', and work in the field professionally. Something just doesn't add up.
Quote:
But that was all the detail I got in the question asked by a teammate. I explained thay it was not how updating logs works. We get logs in a chronological order and reversing them in between is not a desirable thing to do.
Oh?? Then why didn't you mention this was from a 'teammate' at the beginning? Why didn't you post that you were just trying to come up with ideas about a seemingly impossible task, rather than just asking how to do it with (again) no details/context?
Quote:
Besides, running the same job from command line would do the work if it has no time based dependencies such as input data from other sources.
...which wouldn't affect any log files since you'd run it manually, so the question is pointless in this context.
Quote:
But as you might know, some interviewers would stick to their points and would not tell you their hypothetical solutions.
And you keep mentioning 'interviewers'. You do realize many things, such as:
An interviewer can accept ANY answer they'd like.
They can tell you (or not tell you) anything they'd like.
They are trying to gauge how *YOU* think about things, or would approach them.
Spin this any way you'd like. You didn't phrase it as a 'hypothetical' question, nor as something you got asked during an interview, or from a 'teammate'. Again, someone with nine years experience and many 'degrees' and 'certifications' should easily know how to do such things.
Which makes me ask: "Why not?", and "It's NOT impossible, why don't you know the solution?"
Is there a point to this rant? Yes, I mentioned it, because you KEEP POSTING things like this. For someone with nine years experience, degrees/certifications, etc., the 'touch' command should be obvious. And you DID NOT ask how to do it automatically, did you? You asked how to do it...and you were told issues you'd have to deal with, all depending on your environment. Things that 'interviewers' would ask, like "are you syncing your log files?", etc. Things that someone with 'advanced degrees and certifications', and years of experience should know.
Again, you were told that you'd have to edit the log files. There are even 'automatic' ways to do it, using built-in commands, that you should also know. And before going on about "pasting the old slogan", try looking at your posting history:
Where you claim to have looked things up, and couldn't seem to figure out how to pipe commands, use the lp command, or write a basic script: https://www.linuxquestions.org/quest...le-4175623648/
...etc., etc. You ask VERY basic questions, and claim to have 'degrees and certifications', and work in the field professionally. Something just doesn't add up.
Oh?? Then why didn't you mention this was from a 'teammate' at the beginning? Why didn't you post that you were just trying to come up with ideas about a seemingly impossible task, rather than just asking how to do it with (again) no details/context?
...which wouldn't affect any log files since you'd run it manually, so the question is pointless in this context.
And you keep mentioning 'interviewers'. You do realize many things, such as:
An interviewer can accept ANY answer they'd like.
They can tell you (or not tell you) anything they'd like.
They are trying to gauge how *YOU* think about things, or would approach them.
Spin this any way you'd like. You didn't phrase it as a 'hypothetical' question, nor as something you got asked during an interview, or from a 'teammate'. Again, someone with nine years experience and many 'degrees' and 'certifications' should easily know how to do such things.
You like trolling?
What do you want to prove, you moron?
You know, you are the worst kind on the earth. Dig more, you will find posts in which you were to asked to refer to RTFM by others and also many a post from me in which you said you would not answer my posts.
Even dogs change from puppies to better versions of themselves but you have been the same bent tail of a dog.
You will get sympathy from others who are like you.
Note: Loom at the first answer. He did not complain and sound rude like you.
If you don't get a thing, why do you creep your nose into it?
Stay away, you [removed] and rotten animal!
Have you ever been able to answer a question without demoralizing and ridiculing others?
WHAT DO YOU PROVE?
You scoundrel! You spoil moods of others.
STAY AWAY FROM THINGS YOUR BRAIN DOES NOT GET!
Stop Putting Multiple ? Marks. You DON'T even know English.
You are NOTHING!
I am feeling better now. What about you?
BE OFF!
Last edited by devUnix; 10-19-2018 at 09:34 AM.
Reason: More Ridiculing
You like trolling?
What do you want to prove, you moron? You know, you are the worst kind on the earth. Dig more, you will find posts in which you were to asked to refer to RTFM by others and also many a post from me in which you said you would not answer my posts.
Even dogs change from puppies to better versions of themselves but you have been the same bent tail of a dog. You will get sympathy from others who are like you.
Note: Loom at the first answer. He did not complain and sound rude like you. If you don't get a thing, why do you creep your nose into it? Stay away, you shit and rotten animal!
Post reported.
Again, the 'ages old slogan', as you say, isn't addressed: How does someone who claims to have advanced degrees, numerous certifications, and almost a decade of experience, not have the knowledge to do such things on their own? Or at least have an IDEA on how to do it? And if you read post #3 again, I agreed with michaelk, and also asked about your script. And gave you ideas/answers as well, and in post #7. We can only tell you things, we can't understand them for you. If they're too complicated for you, then you need to ask one of your 'teammates' for help.
There isn't much to 'dig'...your posting history speaks for itself; if you don't want to ask clear questions and show your own efforts, you need to (AGAIN) read the LQ Rules and "Question Guidelines".
Quote:
Originally Posted by devUnix
Have you ever been able to answer a question without demoralizing and ridiculing others?
Many, when they show actual effort.
Quote:
Originally Posted by devUnix
WHAT DO YOU PROVE? Shit! You scoundrel! You spoil moods of others.
STAY AWAY FROM THINGS YOUR BRAIN DOES NOT GET! Stop Putting Multiple ? Marks. You DON'T even know English. You are NOTHING! I am feeling better now. What about you? BE OFF!
There a point to your ranting??? Your post was already reported. And I 'get' how to edit log files, and the questions to ask.
You know, you are the worst kind on the earth. Dig more, you will find posts in which you were to asked to refer to RTFM by others and also many a post from me in which you said you would not answer my posts.
Even dogs change from puppies to better versions of themselves but you have been the same bent tail of a dog.
You will get sympathy from others who are like you.
Note: Loom at the first answer. He did not complain and sound rude like you.
If you don't get a thing, why do you creep your nose into it?
Stay away, you shit and rotten animal!
Have you ever been able to answer a question without demoralizing and ridiculing others?
WHAT DO YOU PROVE?
Shit! You scoundrel! You spoil moods of others.
STAY AWAY FROM THINGS YOUR BRAIN DOES NOT GET!
Stop Putting Multiple ? Marks. You DON'T even know English.
You are NOTHING!
I am feeling better now. What about you?
BE OFF!
Easy there, do not pop a blood vessel over a dispute with some guy from the internet. It is just not worth it.
Easy there, do not pop a blood vessel over a dispute with some guy from the internet. It is just not worth it.
@CRTS
That guy always is rude. There are many others who would ask for more details if they didn't get a question.
But in every reply to my posts he has been adding my experiences and certificates and humiliating.
In the last 8 years I have seen his bad comments and have not argued with him. But he has no limits. My limits of tolerating idiots are exhausted now.
He undoes the purpose of discussion here.
If he has a problem with my not being so knowledgeable then he must shut up.
@Tb0ne:
You report it to anybody. Report it to your nation's president too. I don't care. The fact remains same that you are an idiot. And this is my final warning for you as not to ever view my posts and leave your responses unless you have a good reason to do so.
You are more than welcome if you ask for more details and encourage others to do more homework before posting here. But do not ever tell them that YOU wonder why their experiences and certificates show no wit here. Now I wonder how you might have grown up in a family. Do you have children? Do you talk to like this: You have attended schools and you must already know this and that?
You leave no room for adding more knowledge. You don't even think about what the other person might be looking for. It may not be a question that needs an answer. It may be just for ensuring that what one is asking, he knows it and is double-checking it.
Anyways, I am good. You won't change. But I must not have changed my tolerance capacity from 100 to 0.
Your original response was appreciated. But the humiliation you put in there was not. It was unnecessary. Remove that part and your response deserves thanks.
At the risk of being redundant (and getting flamed), I'm still waiting for the OP to respond to #2. As stated, they need to share more information about the job for any advice about how to effect running "as of" 10am at 2pm.
We can't help if you don't give us any information.
I share TB0ne's opinion about certifications but won't be able to express it as politely.
So instead I will ask, why not just run anacron?
I added my profile 8 years ago here. With one technical certificate in my profile description. How he gets "many"?
Besides, having certificates disqualifies one from asking simple questions? Is that the rule of the forum? That is the question, mate. We are supposed to be respectful of others' opinions. This does not mean tolerate humiliation.
At the risk of being redundant (and getting flamed), I'm still waiting for the OP to respond to #2. As stated, they need to share more information about the job for any advice about how to effect running "as of" 10am at 2pm.
We can't help if you don't give us any information.
Nope, as I mentioned before. No more detail is available.
The job only looks for a file that has a timestamp in its name such as data_at_10.data and loads it into a MySQL database. The 10 in the file name says it is meant for the job that runs at 10 am.
I tried to get more details on the question as it is not my own question more have I directly faced it otherwise I would have strongly argued against it because crond does not fire past jobs. Anachron does that in case of the system unavailability.
So, the question was not logical. It didn't surprise me. But still wanted to see if I was not the only one to have thought that way.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.