How to cancel anacron jobs delayed for a certain length of time?
Clash Royale CLAN TAG#URR8PPP
Background: I want to backup some files on my laptop on a daily basis, and there are times when the laptop is shut down for several days in a row.
I tried scheduling the backup as a cron
job and using anacron
to execute missed jobs, but was not sure about the way anacron
works.
If, for example, I start the laptop after a 3-day shutdown, will anacron
execute all 3 missed backup jobs? If this is true, what is the best way to stop anacron
from executing jobs delayed for a certain length of time (> 1 day in this case)?
cron anacron
add a comment |
Background: I want to backup some files on my laptop on a daily basis, and there are times when the laptop is shut down for several days in a row.
I tried scheduling the backup as a cron
job and using anacron
to execute missed jobs, but was not sure about the way anacron
works.
If, for example, I start the laptop after a 3-day shutdown, will anacron
execute all 3 missed backup jobs? If this is true, what is the best way to stop anacron
from executing jobs delayed for a certain length of time (> 1 day in this case)?
cron anacron
add a comment |
Background: I want to backup some files on my laptop on a daily basis, and there are times when the laptop is shut down for several days in a row.
I tried scheduling the backup as a cron
job and using anacron
to execute missed jobs, but was not sure about the way anacron
works.
If, for example, I start the laptop after a 3-day shutdown, will anacron
execute all 3 missed backup jobs? If this is true, what is the best way to stop anacron
from executing jobs delayed for a certain length of time (> 1 day in this case)?
cron anacron
Background: I want to backup some files on my laptop on a daily basis, and there are times when the laptop is shut down for several days in a row.
I tried scheduling the backup as a cron
job and using anacron
to execute missed jobs, but was not sure about the way anacron
works.
If, for example, I start the laptop after a 3-day shutdown, will anacron
execute all 3 missed backup jobs? If this is true, what is the best way to stop anacron
from executing jobs delayed for a certain length of time (> 1 day in this case)?
cron anacron
cron anacron
edited Jan 8 at 12:05
UM-Li
asked Jan 8 at 6:15
UM-LiUM-Li
155
155
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If you have an anacron
job that runs a daily backup, and your system is down for three days, anacron
will run the job once when the system comes online on the fourth day.
To elaborate, anacron
allows you to specify commands to be repeated periodically with a frequency specified in days. When anacron
is invoked (which can happen at boot time, and also during predefined hours of the day), it will read a list of jobs from the /etc/anacrontab
configuration file. For each job, anacron
checks if the job has been executed in last n days. For a daily job, this will be the last 1 day, i.e. today. If the job has not been run in this period, anacron executes the job.
Once the job runs to completion, anacron
records the date of execution in a file, under /var/spool/anacron
. This file is used to check the job's status when anacron is invoked the next day.
Since anacron
only looks at the days elapsed since last execution and the configured frequency of execution, there is no problem of a job being executed multiple times.
A daily anacron job can be set up in the /etc/anacrontab
configuration file using the following syntax:
1 15 backup-job /path/to/backup/script.sh
1 is the frequency of executing the command specified in days, 15 is a delay in minutes added to the execution of the job, 'backup-job' is an identifier, and '/path/to/backup/script.sh' is the command to be executed. You can take a look at man 8 anacron
and man 5 anacrontab
for more details.
add a comment |
In such way the best you can do is to create lock file when the backup is started and remove it on the end of the script. Of course before create you should check if lock file exist and just stop the script if yes. Be careful to check when script is killed from external party and lock file still exist.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f493151%2fhow-to-cancel-anacron-jobs-delayed-for-a-certain-length-of-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you have an anacron
job that runs a daily backup, and your system is down for three days, anacron
will run the job once when the system comes online on the fourth day.
To elaborate, anacron
allows you to specify commands to be repeated periodically with a frequency specified in days. When anacron
is invoked (which can happen at boot time, and also during predefined hours of the day), it will read a list of jobs from the /etc/anacrontab
configuration file. For each job, anacron
checks if the job has been executed in last n days. For a daily job, this will be the last 1 day, i.e. today. If the job has not been run in this period, anacron executes the job.
Once the job runs to completion, anacron
records the date of execution in a file, under /var/spool/anacron
. This file is used to check the job's status when anacron is invoked the next day.
Since anacron
only looks at the days elapsed since last execution and the configured frequency of execution, there is no problem of a job being executed multiple times.
A daily anacron job can be set up in the /etc/anacrontab
configuration file using the following syntax:
1 15 backup-job /path/to/backup/script.sh
1 is the frequency of executing the command specified in days, 15 is a delay in minutes added to the execution of the job, 'backup-job' is an identifier, and '/path/to/backup/script.sh' is the command to be executed. You can take a look at man 8 anacron
and man 5 anacrontab
for more details.
add a comment |
If you have an anacron
job that runs a daily backup, and your system is down for three days, anacron
will run the job once when the system comes online on the fourth day.
To elaborate, anacron
allows you to specify commands to be repeated periodically with a frequency specified in days. When anacron
is invoked (which can happen at boot time, and also during predefined hours of the day), it will read a list of jobs from the /etc/anacrontab
configuration file. For each job, anacron
checks if the job has been executed in last n days. For a daily job, this will be the last 1 day, i.e. today. If the job has not been run in this period, anacron executes the job.
Once the job runs to completion, anacron
records the date of execution in a file, under /var/spool/anacron
. This file is used to check the job's status when anacron is invoked the next day.
Since anacron
only looks at the days elapsed since last execution and the configured frequency of execution, there is no problem of a job being executed multiple times.
A daily anacron job can be set up in the /etc/anacrontab
configuration file using the following syntax:
1 15 backup-job /path/to/backup/script.sh
1 is the frequency of executing the command specified in days, 15 is a delay in minutes added to the execution of the job, 'backup-job' is an identifier, and '/path/to/backup/script.sh' is the command to be executed. You can take a look at man 8 anacron
and man 5 anacrontab
for more details.
add a comment |
If you have an anacron
job that runs a daily backup, and your system is down for three days, anacron
will run the job once when the system comes online on the fourth day.
To elaborate, anacron
allows you to specify commands to be repeated periodically with a frequency specified in days. When anacron
is invoked (which can happen at boot time, and also during predefined hours of the day), it will read a list of jobs from the /etc/anacrontab
configuration file. For each job, anacron
checks if the job has been executed in last n days. For a daily job, this will be the last 1 day, i.e. today. If the job has not been run in this period, anacron executes the job.
Once the job runs to completion, anacron
records the date of execution in a file, under /var/spool/anacron
. This file is used to check the job's status when anacron is invoked the next day.
Since anacron
only looks at the days elapsed since last execution and the configured frequency of execution, there is no problem of a job being executed multiple times.
A daily anacron job can be set up in the /etc/anacrontab
configuration file using the following syntax:
1 15 backup-job /path/to/backup/script.sh
1 is the frequency of executing the command specified in days, 15 is a delay in minutes added to the execution of the job, 'backup-job' is an identifier, and '/path/to/backup/script.sh' is the command to be executed. You can take a look at man 8 anacron
and man 5 anacrontab
for more details.
If you have an anacron
job that runs a daily backup, and your system is down for three days, anacron
will run the job once when the system comes online on the fourth day.
To elaborate, anacron
allows you to specify commands to be repeated periodically with a frequency specified in days. When anacron
is invoked (which can happen at boot time, and also during predefined hours of the day), it will read a list of jobs from the /etc/anacrontab
configuration file. For each job, anacron
checks if the job has been executed in last n days. For a daily job, this will be the last 1 day, i.e. today. If the job has not been run in this period, anacron executes the job.
Once the job runs to completion, anacron
records the date of execution in a file, under /var/spool/anacron
. This file is used to check the job's status when anacron is invoked the next day.
Since anacron
only looks at the days elapsed since last execution and the configured frequency of execution, there is no problem of a job being executed multiple times.
A daily anacron job can be set up in the /etc/anacrontab
configuration file using the following syntax:
1 15 backup-job /path/to/backup/script.sh
1 is the frequency of executing the command specified in days, 15 is a delay in minutes added to the execution of the job, 'backup-job' is an identifier, and '/path/to/backup/script.sh' is the command to be executed. You can take a look at man 8 anacron
and man 5 anacrontab
for more details.
answered Jan 8 at 10:50
HaxielHaxiel
1,763410
1,763410
add a comment |
add a comment |
In such way the best you can do is to create lock file when the backup is started and remove it on the end of the script. Of course before create you should check if lock file exist and just stop the script if yes. Be careful to check when script is killed from external party and lock file still exist.
add a comment |
In such way the best you can do is to create lock file when the backup is started and remove it on the end of the script. Of course before create you should check if lock file exist and just stop the script if yes. Be careful to check when script is killed from external party and lock file still exist.
add a comment |
In such way the best you can do is to create lock file when the backup is started and remove it on the end of the script. Of course before create you should check if lock file exist and just stop the script if yes. Be careful to check when script is killed from external party and lock file still exist.
In such way the best you can do is to create lock file when the backup is started and remove it on the end of the script. Of course before create you should check if lock file exist and just stop the script if yes. Be careful to check when script is killed from external party and lock file still exist.
answered Jan 8 at 7:41
Romeo NinovRomeo Ninov
5,77331928
5,77331928
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f493151%2fhow-to-cancel-anacron-jobs-delayed-for-a-certain-length-of-time%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