Welcome to Centmin Mod Community
Become a Member

Automatic nightly YUM updates with yum-cron

Discussion in 'System Administration' started by eva2000, Sep 28, 2014.

  1. pamamolf

    pamamolf Premium Member Premium Member

    3,456
    331
    83
    May 31, 2014
    Ratings:
    +634
    Local Time:
    12:00 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    I mean i configure it at 00:30 to run every hour by editing the /etc/yum/yum-cron-hourly.conf and not set it to run at 00:30 if i confuse you....

    Ok this is what i did just to get a notification for updates on every hour check without downloading/installing anything:

    Code:
    yum -y install yum-cron
    systemctl enable yum-cron.service
    /bin/systemctl start  yum-cron.service
    nano /etc/yum/yum-cron-hourly.conf

    Code:
    update_messages = yes
    download_updates = no
    apply_updates = no
    system_name = Server5
    emit_via = email
    email_to = [email protected]

    /bin/systemctl restart yum-cron.service

    Yes i think also that is not running :(

    Is there any other way to check that is running ?

    I just test sending mail from ssh to be sure that there is no problem with my vps and is sending fine.
     
    Last edited: Sep 29, 2015
  2. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    tail cron log for cron.hourly
    Code:
     tail -500 /var/log/cron | grep '\/etc\/cron.hourly'
    Sep 28 11:01:01 centos7 CROND[30939]: (root) CMD (run-parts /etc/cron.hourly)
    Sep 28 11:01:01 centos7 run-parts(/etc/cron.hourly)[30939]: starting 0anacron
    Sep 28 11:01:01 centos7 run-parts(/etc/cron.hourly)[30948]: finished 0anacron
    Sep 28 11:01:01 centos7 run-parts(/etc/cron.hourly)[30939]: starting 0yum-hourly.cron
    Sep 28 11:01:23 centos7 run-parts(/etc/cron.hourly)[30982]: finished 0yum-hourly.cron
    then check if finished for 0yum-hourly.cron which is /etc/cron.hourly/0yum-hourly.cron
    Code:
    #!/bin/bash
    
    # Only run if this flag is set. The flag is created by the yum-cron init
    # script when the service is started -- this allows one to use chkconfig and
    # the standard "service stop|start" commands to enable or disable yum-cron.
    if [[ ! -f /var/lock/subsys/yum-cron ]]; then
      exit 0
    fi
    
    # Action!
    exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
    
    that runs
    Code:
    exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
    of course if you have no updates = no notifications
     
  3. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    check spam/junk folder too
     
  4. pamamolf

    pamamolf Premium Member Premium Member

    3,456
    331
    83
    May 31, 2014
    Ratings:
    +634
    Local Time:
    12:00 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    Code:
    Sep 28 21:01:01 vultr run-parts(/etc/cron.hourly)[27391]: finished 0yum-hourly.cron
    Sep 28 22:01:01 vultr CROND[7125]: (root) CMD (run-parts /etc/cron.hourly)
    Sep 28 22:01:01 vultr run-parts(/etc/cron.hourly)[7125]: starting 0anacron
    Sep 28 22:01:01 vultr run-parts(/etc/cron.hourly)[7134]: finished 0anacron
    Sep 28 22:01:01 vultr run-parts(/etc/cron.hourly)[7125]: starting 0yum-hourly.cron
    Sep 28 22:14:29 vultr run-parts(/etc/cron.hourly)[9760]: finished 0yum-hourly.cron
    [[email protected] ~]# date
    Mon Sep 28 22:28:54 UTC 2015
    spam junk folder empty .....

    I didn't understant what you mean with:

    Copy the codde to .sh file and chmod +x and run it?

    I try to run manually this but nothing:

    Code:
    [[email protected] ~]# exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
    
    
    and there are updates:

    Code:
    [[email protected] ~]# yum upgrade
    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.fr.planethoster.net
    * epel: fedora.cu.be
    * extras: centos.quelquesmots.fr
    * rpmforge: mirror.ate.info
    * updates: centos.mirror.fr.planethoster.net
    153 packages excluded due to repository priority protections
    Resolving Dependencies
    --> Running transaction check
    ---> Package grub2.x86_64 1:2.02-0.17.el7_1.4 will be updated
    ---> Package grub2.x86_64 1:2.02-0.17.0.1.el7.centos.4 will be an update
    ---> Package grub2-tools.x86_64 1:2.02-0.17.el7_1.4 will be updated
    ---> Package grub2-tools.x86_64 1:2.02-0.17.0.1.el7.centos.4 will be an update
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==============================================================================================================================================
    Package                        Arch                      Version                                            Repository                  Size
    ==============================================================================================================================================
    Updating:
    grub2                          x86_64                    1:2.02-0.17.0.1.el7.centos.4                       updates                    1.5 M
    grub2-tools                    x86_64                    1:2.02-0.17.0.1.el7.centos.4                       updates                    3.3 M
    
    Transaction Summary
    ==============================================================================================================================================
    Upgrade  2 Packages
    
    Total download size: 4.7 M
     
  5. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    log tailed shows
    Code:
    Sep 28 22:14:29 vultr run-parts(/etc/cron.hourly)[9760]: finished 0yum-hourly.cron
    means hourly 0yum-hourly.cron finished
     
  6. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    because of random_sleep setting
    Code:
    # Maximum amout of time to randomly sleep, in minutes.  The program
    # will sleep for a random amount of time between 0 and random_sleep
    # minutes before running.  This is useful for e.g. staggering the
    # times that multiple systems will access update servers.  If
    # random_sleep is 0 or negative, the program will run immediately.
    random_sleep = 15
     
    • Like Like x 1
  7. pamamolf

    pamamolf Premium Member Premium Member

    3,456
    331
    83
    May 31, 2014
    Ratings:
    +634
    Local Time:
    12:00 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    Ok i think i found the problem let's wait a few minutes to be here 02:00 and see :)

    I will wait also the 15 minutes for random_sleep....
     
    Last edited: Sep 29, 2015
  8. pamamolf

    pamamolf Premium Member Premium Member

    3,456
    331
    83
    May 31, 2014
    Ratings:
    +634
    Local Time:
    12:00 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    Yup working now as i had a typo on my yum-cron-hourly.conf file :)

    Thanks !!!!!
     
    • Like Like x 1
  9. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Great :)
     
  10. rdan

    rdan Well-Known Member

    4,613
    1,112
    113
    May 25, 2014
    Ratings:
    +1,638
    Local Time:
    5:00 PM
    Mainline
    10.2
    Thanks a lot for the sed command, that was so hard :D
     
    • Like Like x 1
  11. rdan

    rdan Well-Known Member

    4,613
    1,112
    113
    May 25, 2014
    Ratings:
    +1,638
    Local Time:
    5:00 PM
    Mainline
    10.2
    • Informative Informative x 1
  12. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    • Like Like x 1
  13. rdan

    rdan Well-Known Member

    4,613
    1,112
    113
    May 25, 2014
    Ratings:
    +1,638
    Local Time:
    5:00 PM
    Mainline
    10.2
    So to update mine?
    Code:
    sed -i 's|^update_cmd = security|update_cmd = default|' /etc/yum/yum-cron-hourly.conf
    egrep '^update_cmd' /etc/yum/yum-cron-hourly.conf
    service yum-cron restart
     
  14. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yup
     
    • Like Like x 1
  15. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    FYI, just a heads up I am working on my own centmin mod specific yumupdates.sh script based on code from yum-cron to take into account variable 3rd party yum repos centmin mod uses Third Party YUM Repos with Centmin Mod - CentminMod.com LEMP Nginx web stack for CentOS :)

    sample email notification when there's updates
    Code:
    Mon Jan 18 14:28:32 UTC 2016
    New updates available for host domain.com
    Loaded plugins: fastestmirror, priorities, security
    1702 packages excluded due to repository priority protections
    
    remi-release.noarch                     6.6-2.el6.remi                      remi
     
    Last edited: Jan 19, 2016
    • Like Like x 4
    • Informative Informative x 1
  16. BobbyWibowo

    BobbyWibowo Active Member

    178
    39
    28
    Jul 30, 2015
    Indonesia
    Ratings:
    +62
    Local Time:
    4:00 PM
    1.17.x
    10.1.x
    Still broken?
     
  17. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    should be
     
  18. BobbyWibowo

    BobbyWibowo Active Member

    178
    39
    28
    Jul 30, 2015
    Indonesia
    Ratings:
    +62
    Local Time:
    4:00 PM
    1.17.x
    10.1.x
    Oh well, I'll just disable the nightly update, and set the hourly update to update anything o_O
     
  19. eva2000

    eva2000 Administrator Staff Member

    41,386
    9,297
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,261
    Local Time:
    7:00 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    • Agree Agree x 1
  20. pamamolf

    pamamolf Premium Member Premium Member

    3,456
    331
    83
    May 31, 2014
    Ratings:
    +634
    Local Time:
    12:00 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    As an option ?

    Easy to enable/disable ?