automated bash script execution using cron
I have been trying to use the cron package for scheduled bash script execution as is generally intended, and have found almost everything I need via this resource here
However the part I was unable to find, was the means for which I can set a beginning and end for a particular cron schedule to be conditional, ie I suppose I wanted a particular cron job to only be executed in march daily, and to then continue in april if say some binary variable (whose value is determined from some sort of assessment of the cron job's march output) is 1, and for the the cron job to be terminated until further notice if it's value is 0.
I apologise if my phrasing is unclear, constructive criticism is appreciated.
command-line bash scripts cron
|
show 2 more comments
I have been trying to use the cron package for scheduled bash script execution as is generally intended, and have found almost everything I need via this resource here
However the part I was unable to find, was the means for which I can set a beginning and end for a particular cron schedule to be conditional, ie I suppose I wanted a particular cron job to only be executed in march daily, and to then continue in april if say some binary variable (whose value is determined from some sort of assessment of the cron job's march output) is 1, and for the the cron job to be terminated until further notice if it's value is 0.
I apologise if my phrasing is unclear, constructive criticism is appreciated.
command-line bash scripts cron
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
1
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) usingtext -f /path/to/runfile && rest-of-your-cronjob- kind of like how/forcefsckused to be used on reboot
– steeldriver
5 hours ago
|
show 2 more comments
I have been trying to use the cron package for scheduled bash script execution as is generally intended, and have found almost everything I need via this resource here
However the part I was unable to find, was the means for which I can set a beginning and end for a particular cron schedule to be conditional, ie I suppose I wanted a particular cron job to only be executed in march daily, and to then continue in april if say some binary variable (whose value is determined from some sort of assessment of the cron job's march output) is 1, and for the the cron job to be terminated until further notice if it's value is 0.
I apologise if my phrasing is unclear, constructive criticism is appreciated.
command-line bash scripts cron
I have been trying to use the cron package for scheduled bash script execution as is generally intended, and have found almost everything I need via this resource here
However the part I was unable to find, was the means for which I can set a beginning and end for a particular cron schedule to be conditional, ie I suppose I wanted a particular cron job to only be executed in march daily, and to then continue in april if say some binary variable (whose value is determined from some sort of assessment of the cron job's march output) is 1, and for the the cron job to be terminated until further notice if it's value is 0.
I apologise if my phrasing is unclear, constructive criticism is appreciated.
command-line bash scripts cron
command-line bash scripts cron
edited 5 hours ago
Adam
asked 5 hours ago
AdamAdam
1267
1267
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
1
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) usingtext -f /path/to/runfile && rest-of-your-cronjob- kind of like how/forcefsckused to be used on reboot
– steeldriver
5 hours ago
|
show 2 more comments
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
1
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) usingtext -f /path/to/runfile && rest-of-your-cronjob- kind of like how/forcefsckused to be used on reboot
– steeldriver
5 hours ago
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
1
1
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) using
text -f /path/to/runfile && rest-of-your-cronjob - kind of like how /forcefsck used to be used on reboot– steeldriver
5 hours ago
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) using
text -f /path/to/runfile && rest-of-your-cronjob - kind of like how /forcefsck used to be used on reboot– steeldriver
5 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
You can put variables in the crontab file, so you can have
EXECUTE_JOB=1
Then implement the condition with this /bin/sh construct
* * * * * [ "$EXECUTE_JOB" = "1" ] && your existing job here
Then, on April 1, you can adjust the value of that variable accordingly
ok thankyou for this
– Adam
5 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1121465%2fautomated-bash-script-execution-using-cron%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can put variables in the crontab file, so you can have
EXECUTE_JOB=1
Then implement the condition with this /bin/sh construct
* * * * * [ "$EXECUTE_JOB" = "1" ] && your existing job here
Then, on April 1, you can adjust the value of that variable accordingly
ok thankyou for this
– Adam
5 hours ago
add a comment |
You can put variables in the crontab file, so you can have
EXECUTE_JOB=1
Then implement the condition with this /bin/sh construct
* * * * * [ "$EXECUTE_JOB" = "1" ] && your existing job here
Then, on April 1, you can adjust the value of that variable accordingly
ok thankyou for this
– Adam
5 hours ago
add a comment |
You can put variables in the crontab file, so you can have
EXECUTE_JOB=1
Then implement the condition with this /bin/sh construct
* * * * * [ "$EXECUTE_JOB" = "1" ] && your existing job here
Then, on April 1, you can adjust the value of that variable accordingly
You can put variables in the crontab file, so you can have
EXECUTE_JOB=1
Then implement the condition with this /bin/sh construct
* * * * * [ "$EXECUTE_JOB" = "1" ] && your existing job here
Then, on April 1, you can adjust the value of that variable accordingly
answered 5 hours ago
glenn jackmanglenn jackman
12.5k2545
12.5k2545
ok thankyou for this
– Adam
5 hours ago
add a comment |
ok thankyou for this
– Adam
5 hours ago
ok thankyou for this
– Adam
5 hours ago
ok thankyou for this
– Adam
5 hours ago
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1121465%2fautomated-bash-script-execution-using-cron%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where is this variable supposed to reside?
– glenn jackman
5 hours ago
ok well what I had envisaged, which obviously hypothetical, I'm very new to things, was a separate cron schedule to perform the "evaluation" of the original cron job, and pipe the output to the "cron job continuity variable"
– Adam
5 hours ago
so I suppose it would need to be an environmental variable I would need to create which again is another learning process I'm in the middle of
– Adam
5 hours ago
@user535733 is this the kind of thing you are refering to? tldp.org/LDP/abs/html/testconstructs.html
– Adam
5 hours ago
1
You could arrange for the March cronjob to create (or delete) a file, and for the April cronjob to test for the file's presence (or absence) using
text -f /path/to/runfile && rest-of-your-cronjob- kind of like how/forcefsckused to be used on reboot– steeldriver
5 hours ago