How to schedule yum auto update to run only during the night?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I want to set up up yum to auto update the system using yum-cron. But my internet connection is very limited and I don't want the update process to hog the tiny bit of internet that is available and make the computer usage for everybody on the network miserable.
How can I set up yum to check and download updates automatically, but only between 2am and 6am?
centos rhel cron yum
add a comment |Â
up vote
4
down vote
favorite
I want to set up up yum to auto update the system using yum-cron. But my internet connection is very limited and I don't want the update process to hog the tiny bit of internet that is available and make the computer usage for everybody on the network miserable.
How can I set up yum to check and download updates automatically, but only between 2am and 6am?
centos rhel cron yum
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I want to set up up yum to auto update the system using yum-cron. But my internet connection is very limited and I don't want the update process to hog the tiny bit of internet that is available and make the computer usage for everybody on the network miserable.
How can I set up yum to check and download updates automatically, but only between 2am and 6am?
centos rhel cron yum
I want to set up up yum to auto update the system using yum-cron. But my internet connection is very limited and I don't want the update process to hog the tiny bit of internet that is available and make the computer usage for everybody on the network miserable.
How can I set up yum to check and download updates automatically, but only between 2am and 6am?
centos rhel cron yum
edited Nov 5 '17 at 22:06
peterh
3,97092755
3,97092755
asked Nov 5 '17 at 18:10
Kenny Blankenship
234
234
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
Well, if it were me, I would set up a cron job (for root
) that starts at 2am every day. Like so:
0 2 * * * /bin/yum -y update
It's about as KISS as it can get!
add a comment |Â
up vote
3
down vote
Here's a short answer. Run the following command as the root user:
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
A detailed explanation follows.
There are several utilities for running scheduled jobs on Unix systems:
cron
anacron
fcron
hcron
The cron
utility is the de facto standard Unix utility for performing scheduled tasks. One disadvantage of cron
is that the task may not be performed if the system is down for some reason
The anacron
utility was created for use cases in which the host system may not be up continuously:
anacron is a computer program that performs periodic command scheduling, which is traditionally done by cron, but without assuming that the system is running continuously.
The fcron
utility is a newer version that is also designed to handle this kind of situation:
fcron is a computer program [...] performs periodic command scheduling. [fcron] does not assume that the system is running continuously, and can run in systems that do not run all the time or regularly. It aims to replace Vixie-cron and Anacron with a single integrated program, providing many features missing from the original Cron daemon.
The hcron
utility is a much more feature-rich alternative:
hcron [brings something new to the table] in a number of really useful and practical ways. For example:
- events are stored individually, each in their own file, rather than all in a single file
- events are organized hierarchically in the filesystem rather than as a table in a single file
- events are named and referenceable
- events are defined as multiple key=value settings rather than a ordered columns on a single line
- hcron is network oriented rather than system oriented
- support for template events to reducing and reuse settings
- support for failover events if an event cannot be spawned
- support for settings and working with variables
If you don't need the additional features of any of the other variants then the simplest to use would be cron
. The typical workflow for cron
is to create a so-called cron job for a given task, which consists of a command to run and a pattern which specifies when to run it. The syntax for the time pattern is given by the following:
# âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ minute (0 - 59)
# â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ hour (0 - 23)
# â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of month (1 - 31)
# â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ month (1 - 12)
# â â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of week (0 - 6) (Sunday to Saturday;
# â â â â â 7 is also Sunday on some systems)
# â â â â âÂÂ
# â â â â âÂÂ
# * * * * * command to execute
The cron daemon runs every minute and checks all active cron jobs to see if any of the jobs have patterns which match the current time. For example, to run a job at 2:00AM you would want the minute value to be 0, the hour value to be 2, and the day-of-month, month, and day-of-week values to be unrestricted. This would be denoted as follows:
0 2 * * * command
The syntax might take a little getting used to, so here's a web-based utility which will help you generate cron job expressions:
- https://crontab-generator.org/
And here's another web-based tool that you might find useful:
- https://crontab.guru/
It does the reverse - it allows you to enter a time pattern and it displays it in English.
There are several different ways to deploy cron jobs. There is a main crontab file and several subdirectories of /etc/
which are intended for system cron jobs:
/etc/crontab
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
For more information about this see, for instance, the relevant section from the CentOS Deployment Guide:
- Configuring Cron Tasks
The easiest thing to do might be to add a crontab file to the /etc/crontab.d
directory, e.g.
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
You might want to set the MAILTO variable to your preferred administrative email address so that you are informed if the job fails.
You should also be aware that the cronjobs run in a different environment than your user, which is a common gotcha and source of frustration. See, for example, the following post:
- Why crontab scripts are not working?
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
Well, if it were me, I would set up a cron job (for root
) that starts at 2am every day. Like so:
0 2 * * * /bin/yum -y update
It's about as KISS as it can get!
add a comment |Â
up vote
6
down vote
accepted
Well, if it were me, I would set up a cron job (for root
) that starts at 2am every day. Like so:
0 2 * * * /bin/yum -y update
It's about as KISS as it can get!
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
Well, if it were me, I would set up a cron job (for root
) that starts at 2am every day. Like so:
0 2 * * * /bin/yum -y update
It's about as KISS as it can get!
Well, if it were me, I would set up a cron job (for root
) that starts at 2am every day. Like so:
0 2 * * * /bin/yum -y update
It's about as KISS as it can get!
edited Nov 5 '17 at 19:23
answered Nov 5 '17 at 19:16
maulinglawns
5,6782923
5,6782923
add a comment |Â
add a comment |Â
up vote
3
down vote
Here's a short answer. Run the following command as the root user:
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
A detailed explanation follows.
There are several utilities for running scheduled jobs on Unix systems:
cron
anacron
fcron
hcron
The cron
utility is the de facto standard Unix utility for performing scheduled tasks. One disadvantage of cron
is that the task may not be performed if the system is down for some reason
The anacron
utility was created for use cases in which the host system may not be up continuously:
anacron is a computer program that performs periodic command scheduling, which is traditionally done by cron, but without assuming that the system is running continuously.
The fcron
utility is a newer version that is also designed to handle this kind of situation:
fcron is a computer program [...] performs periodic command scheduling. [fcron] does not assume that the system is running continuously, and can run in systems that do not run all the time or regularly. It aims to replace Vixie-cron and Anacron with a single integrated program, providing many features missing from the original Cron daemon.
The hcron
utility is a much more feature-rich alternative:
hcron [brings something new to the table] in a number of really useful and practical ways. For example:
- events are stored individually, each in their own file, rather than all in a single file
- events are organized hierarchically in the filesystem rather than as a table in a single file
- events are named and referenceable
- events are defined as multiple key=value settings rather than a ordered columns on a single line
- hcron is network oriented rather than system oriented
- support for template events to reducing and reuse settings
- support for failover events if an event cannot be spawned
- support for settings and working with variables
If you don't need the additional features of any of the other variants then the simplest to use would be cron
. The typical workflow for cron
is to create a so-called cron job for a given task, which consists of a command to run and a pattern which specifies when to run it. The syntax for the time pattern is given by the following:
# âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ minute (0 - 59)
# â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ hour (0 - 23)
# â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of month (1 - 31)
# â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ month (1 - 12)
# â â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of week (0 - 6) (Sunday to Saturday;
# â â â â â 7 is also Sunday on some systems)
# â â â â âÂÂ
# â â â â âÂÂ
# * * * * * command to execute
The cron daemon runs every minute and checks all active cron jobs to see if any of the jobs have patterns which match the current time. For example, to run a job at 2:00AM you would want the minute value to be 0, the hour value to be 2, and the day-of-month, month, and day-of-week values to be unrestricted. This would be denoted as follows:
0 2 * * * command
The syntax might take a little getting used to, so here's a web-based utility which will help you generate cron job expressions:
- https://crontab-generator.org/
And here's another web-based tool that you might find useful:
- https://crontab.guru/
It does the reverse - it allows you to enter a time pattern and it displays it in English.
There are several different ways to deploy cron jobs. There is a main crontab file and several subdirectories of /etc/
which are intended for system cron jobs:
/etc/crontab
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
For more information about this see, for instance, the relevant section from the CentOS Deployment Guide:
- Configuring Cron Tasks
The easiest thing to do might be to add a crontab file to the /etc/crontab.d
directory, e.g.
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
You might want to set the MAILTO variable to your preferred administrative email address so that you are informed if the job fails.
You should also be aware that the cronjobs run in a different environment than your user, which is a common gotcha and source of frustration. See, for example, the following post:
- Why crontab scripts are not working?
add a comment |Â
up vote
3
down vote
Here's a short answer. Run the following command as the root user:
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
A detailed explanation follows.
There are several utilities for running scheduled jobs on Unix systems:
cron
anacron
fcron
hcron
The cron
utility is the de facto standard Unix utility for performing scheduled tasks. One disadvantage of cron
is that the task may not be performed if the system is down for some reason
The anacron
utility was created for use cases in which the host system may not be up continuously:
anacron is a computer program that performs periodic command scheduling, which is traditionally done by cron, but without assuming that the system is running continuously.
The fcron
utility is a newer version that is also designed to handle this kind of situation:
fcron is a computer program [...] performs periodic command scheduling. [fcron] does not assume that the system is running continuously, and can run in systems that do not run all the time or regularly. It aims to replace Vixie-cron and Anacron with a single integrated program, providing many features missing from the original Cron daemon.
The hcron
utility is a much more feature-rich alternative:
hcron [brings something new to the table] in a number of really useful and practical ways. For example:
- events are stored individually, each in their own file, rather than all in a single file
- events are organized hierarchically in the filesystem rather than as a table in a single file
- events are named and referenceable
- events are defined as multiple key=value settings rather than a ordered columns on a single line
- hcron is network oriented rather than system oriented
- support for template events to reducing and reuse settings
- support for failover events if an event cannot be spawned
- support for settings and working with variables
If you don't need the additional features of any of the other variants then the simplest to use would be cron
. The typical workflow for cron
is to create a so-called cron job for a given task, which consists of a command to run and a pattern which specifies when to run it. The syntax for the time pattern is given by the following:
# âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ minute (0 - 59)
# â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ hour (0 - 23)
# â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of month (1 - 31)
# â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ month (1 - 12)
# â â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of week (0 - 6) (Sunday to Saturday;
# â â â â â 7 is also Sunday on some systems)
# â â â â âÂÂ
# â â â â âÂÂ
# * * * * * command to execute
The cron daemon runs every minute and checks all active cron jobs to see if any of the jobs have patterns which match the current time. For example, to run a job at 2:00AM you would want the minute value to be 0, the hour value to be 2, and the day-of-month, month, and day-of-week values to be unrestricted. This would be denoted as follows:
0 2 * * * command
The syntax might take a little getting used to, so here's a web-based utility which will help you generate cron job expressions:
- https://crontab-generator.org/
And here's another web-based tool that you might find useful:
- https://crontab.guru/
It does the reverse - it allows you to enter a time pattern and it displays it in English.
There are several different ways to deploy cron jobs. There is a main crontab file and several subdirectories of /etc/
which are intended for system cron jobs:
/etc/crontab
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
For more information about this see, for instance, the relevant section from the CentOS Deployment Guide:
- Configuring Cron Tasks
The easiest thing to do might be to add a crontab file to the /etc/crontab.d
directory, e.g.
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
You might want to set the MAILTO variable to your preferred administrative email address so that you are informed if the job fails.
You should also be aware that the cronjobs run in a different environment than your user, which is a common gotcha and source of frustration. See, for example, the following post:
- Why crontab scripts are not working?
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Here's a short answer. Run the following command as the root user:
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
A detailed explanation follows.
There are several utilities for running scheduled jobs on Unix systems:
cron
anacron
fcron
hcron
The cron
utility is the de facto standard Unix utility for performing scheduled tasks. One disadvantage of cron
is that the task may not be performed if the system is down for some reason
The anacron
utility was created for use cases in which the host system may not be up continuously:
anacron is a computer program that performs periodic command scheduling, which is traditionally done by cron, but without assuming that the system is running continuously.
The fcron
utility is a newer version that is also designed to handle this kind of situation:
fcron is a computer program [...] performs periodic command scheduling. [fcron] does not assume that the system is running continuously, and can run in systems that do not run all the time or regularly. It aims to replace Vixie-cron and Anacron with a single integrated program, providing many features missing from the original Cron daemon.
The hcron
utility is a much more feature-rich alternative:
hcron [brings something new to the table] in a number of really useful and practical ways. For example:
- events are stored individually, each in their own file, rather than all in a single file
- events are organized hierarchically in the filesystem rather than as a table in a single file
- events are named and referenceable
- events are defined as multiple key=value settings rather than a ordered columns on a single line
- hcron is network oriented rather than system oriented
- support for template events to reducing and reuse settings
- support for failover events if an event cannot be spawned
- support for settings and working with variables
If you don't need the additional features of any of the other variants then the simplest to use would be cron
. The typical workflow for cron
is to create a so-called cron job for a given task, which consists of a command to run and a pattern which specifies when to run it. The syntax for the time pattern is given by the following:
# âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ minute (0 - 59)
# â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ hour (0 - 23)
# â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of month (1 - 31)
# â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ month (1 - 12)
# â â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of week (0 - 6) (Sunday to Saturday;
# â â â â â 7 is also Sunday on some systems)
# â â â â âÂÂ
# â â â â âÂÂ
# * * * * * command to execute
The cron daemon runs every minute and checks all active cron jobs to see if any of the jobs have patterns which match the current time. For example, to run a job at 2:00AM you would want the minute value to be 0, the hour value to be 2, and the day-of-month, month, and day-of-week values to be unrestricted. This would be denoted as follows:
0 2 * * * command
The syntax might take a little getting used to, so here's a web-based utility which will help you generate cron job expressions:
- https://crontab-generator.org/
And here's another web-based tool that you might find useful:
- https://crontab.guru/
It does the reverse - it allows you to enter a time pattern and it displays it in English.
There are several different ways to deploy cron jobs. There is a main crontab file and several subdirectories of /etc/
which are intended for system cron jobs:
/etc/crontab
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
For more information about this see, for instance, the relevant section from the CentOS Deployment Guide:
- Configuring Cron Tasks
The easiest thing to do might be to add a crontab file to the /etc/crontab.d
directory, e.g.
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
You might want to set the MAILTO variable to your preferred administrative email address so that you are informed if the job fails.
You should also be aware that the cronjobs run in a different environment than your user, which is a common gotcha and source of frustration. See, for example, the following post:
- Why crontab scripts are not working?
Here's a short answer. Run the following command as the root user:
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
A detailed explanation follows.
There are several utilities for running scheduled jobs on Unix systems:
cron
anacron
fcron
hcron
The cron
utility is the de facto standard Unix utility for performing scheduled tasks. One disadvantage of cron
is that the task may not be performed if the system is down for some reason
The anacron
utility was created for use cases in which the host system may not be up continuously:
anacron is a computer program that performs periodic command scheduling, which is traditionally done by cron, but without assuming that the system is running continuously.
The fcron
utility is a newer version that is also designed to handle this kind of situation:
fcron is a computer program [...] performs periodic command scheduling. [fcron] does not assume that the system is running continuously, and can run in systems that do not run all the time or regularly. It aims to replace Vixie-cron and Anacron with a single integrated program, providing many features missing from the original Cron daemon.
The hcron
utility is a much more feature-rich alternative:
hcron [brings something new to the table] in a number of really useful and practical ways. For example:
- events are stored individually, each in their own file, rather than all in a single file
- events are organized hierarchically in the filesystem rather than as a table in a single file
- events are named and referenceable
- events are defined as multiple key=value settings rather than a ordered columns on a single line
- hcron is network oriented rather than system oriented
- support for template events to reducing and reuse settings
- support for failover events if an event cannot be spawned
- support for settings and working with variables
If you don't need the additional features of any of the other variants then the simplest to use would be cron
. The typical workflow for cron
is to create a so-called cron job for a given task, which consists of a command to run and a pattern which specifies when to run it. The syntax for the time pattern is given by the following:
# âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ minute (0 - 59)
# â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ hour (0 - 23)
# â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of month (1 - 31)
# â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ month (1 - 12)
# â â â â âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ day of week (0 - 6) (Sunday to Saturday;
# â â â â â 7 is also Sunday on some systems)
# â â â â âÂÂ
# â â â â âÂÂ
# * * * * * command to execute
The cron daemon runs every minute and checks all active cron jobs to see if any of the jobs have patterns which match the current time. For example, to run a job at 2:00AM you would want the minute value to be 0, the hour value to be 2, and the day-of-month, month, and day-of-week values to be unrestricted. This would be denoted as follows:
0 2 * * * command
The syntax might take a little getting used to, so here's a web-based utility which will help you generate cron job expressions:
- https://crontab-generator.org/
And here's another web-based tool that you might find useful:
- https://crontab.guru/
It does the reverse - it allows you to enter a time pattern and it displays it in English.
There are several different ways to deploy cron jobs. There is a main crontab file and several subdirectories of /etc/
which are intended for system cron jobs:
/etc/crontab
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
For more information about this see, for instance, the relevant section from the CentOS Deployment Guide:
- Configuring Cron Tasks
The easiest thing to do might be to add a crontab file to the /etc/crontab.d
directory, e.g.
cat <<HEREDOC > /etc/crontab.d/update-yum.crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2 * * * yum -y update
HEREDOC
You might want to set the MAILTO variable to your preferred administrative email address so that you are informed if the job fails.
You should also be aware that the cronjobs run in a different environment than your user, which is a common gotcha and source of frustration. See, for example, the following post:
- Why crontab scripts are not working?
answered Nov 6 '17 at 1:14
igal
4,830930
4,830930
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402698%2fhow-to-schedule-yum-auto-update-to-run-only-during-the-night%23new-answer', 'question_page');
);
Post as a guest
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
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
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