Announcement

Collapse
No announcement yet.

Cron Task Schedular

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cron Task Schedular

    Just a quick question, I set up a couple of scheduled task, and I wanted them to run at like 2:00am. However, when I sat the frequency, I set up the time I wanted it to run, then was unable to set it, until I marked to run at system startup. The thing is I wasn't planning on turning my computer off especially since I need these task to run at that time. Actually it's the update & upgrade option, I have to run it at that time because I have a download limit, and at that time I have a free period from 2-6. Then at 6:05 I have a reboot scheduled, for those times a reboot is required.

    Now that I've told all that, my question is, "why do we have to set it to run at startup?". Will it actually run a the time I sat, or will it only run if I restart my computer?

    #2
    Could you...

    Could you tell what and how you are doing ?


    At here:

    Using the KDE graphical tool to edit the Cron.

    Normal user (Personal Cron) can start the KCron from the KDE System settings > Task Scheduler.

    As root (System Cron) can be edited with the command:
    Code:
    kdesudo kcmshell4 kcm_cron
    Starting the KCron with administrative privileges - System Cron.

    1. adding the commands
    2. Run as root
    3. Run every day
    4. Hours and minutes
    5. OK



    and the System Cron has the tasks.



    Code:
    :~$ sudo cat /etc/crontab
    #No comment
    SHELL=/bin/sh
    
    #No comment
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    #No comment
    17 * * * *      root    cd / && run-parts --report /etc/cron.hourly
    
    #No comment
    25 6 * * *      root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    
    #No comment
    47 6 * * 7      root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    
    #No comment
    52 6 1 * *      root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
    
    #No comment
    0 2 * * *       root    apt-get update & apt-get upgrade
    
    
    # File generated by KCron the Tuesday, January 07, 2014 10:58 PM.

    Links

    KDE UserBase: http://userbase.kde.org/KCron
    The KCron Handbook online: http://docs.kde.org/development/en/kdeadmin/kcron/
    The Ubuntu community Cron HowTo: https://help.ubuntu.com/community/CronHowto


    About cron upgrades

    I would use the -d option with the cron upgrades

    man apt-get
    -d, --download-only
    Download only; package files are only retrieved, not unpacked or installed.
    and then run the upgrade again when I'm looking.
    Last edited by Rog132; Jan 07, 2014, 03:31 PM.
    A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
    Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

    Comment


      #3
      Originally posted by Rog132 View Post
      Could you tell what and how you are doing ?
      I entered these commands in, as a user, I couldn't figure out how to set as root.

      sudo apt-get update && sudo apt-get dist-upgrade

      Then I clicked "enable task", clicked "run every day", set the time frame (2-6am), tried to click "OK", but it was greyed out, all I could do was click "Runt at system bootup", which then locked everything down.

      I then set up another one the exact same way, but the command was

      sudo reboot

      I would use the -d option with the cron upgrades

      man apt-get


      and then run the upgrade again when I'm looking.
      Let me ask, what is the reason behind downloading, and waiting to install? I'm just curious, I'm trying to learn everything I can, which is why I'm asking that.

      Thank you for all the instructions, I will put them in my notebook so I'll have them next time.

      Comment


        #4
        IF

        I entered these commands in, as a user, I couldn't figure out how to set as root.

        sudo apt-get update && sudo apt-get dist-upgrade

        Then I clicked "enable task", clicked "run every day", set the time frame (2-6am), tried to click "OK", but it was greyed out, all I could do was click "Runt at system bootup", which then locked everything down.

        I then set up another one the exact same way, but the command was

        sudo reboot
        If I do as you are telling:

        1) entering the commands: sudo apt-get update && sudo apt-get dist-upgrade
        2) clicking the run every day
        3) setting the start hours: 2am

        The Ok button is grayed out as the KCron is waiting the minutes.



        If pick the minutes (picking the 0). The KCron is telling that the task can be executed 2.00 am and the OK button is released.




        If you click the 'Run at system bootup' the task will be executed at the bootup.



        Let me ask, what is the reason behind downloading, and waiting to install?
        Well - If there are problems with the update & upgrade the apt could need instructions what to do.

        My opinion is that the easiest way is:

        1) download all packages.
        2) install the packages later - you can be offline when you are installing.

        then you don't need to check if the cron job was succesful.



        Something different

        The Root option to the KDE System Settings. The KCron desktop file is at : /usr/share/kde4/services/kcm_cron.desktop

        Copying it to the /usr/share/kde4/services/kcm_cron_root.desktop

        adding there line: X-KDE-SubstituteUID=true
        changing the icon
        adding the Root word to the name and to the comment.
        cleaning a bit....

        now:
        Code:
        [Desktop Entry]
        Exec=kcmshell4 kcm_cron
        Icon=view-time-schedule-baselined
        
        X-DocPath=kcron/index.html
        
        Type=Service
        X-KDE-ServiceTypes=KCModule
        X-KDE-Library=kcm_cron
        X-KDE-ParentApp=kcontrol
        X-KDE-SubstituteUID=true
        
        X-KDE-System-Settings-Parent-Category=system-administration
        
        Name=Task Scheduler Root
        
        Comment=Configure and schedule tasks as Root
        
        X-KDE-Keywords=cron,crontab,scheduled,tasks,task,schedule,vixie
        
        Categories=Qt;KDE;X-KDE-settings-system;
        and there is the Root KCron:



        With the password query:

        A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
        Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

        Comment


          #5
          For completeness:
          putting "sudo apt-get update && sudo apt-get dist-upgrade" in user cron will not work as sudo would need a password authentication which it can't get from automated run. There are ways around that, but it's better to use root's (or system) cron without sudo.

          download only is generally a better option as the upgrade may need to ask questions (which also can't be answered when running with cron), so you'd have to use the -y (-y, --yes, --assume-yes) option with apt-get to assume "yes" answer to questions...and this can lead to undesirable (or even catastrophic) results (especially with dist-upgrade).

          EDIT:
          There is also the "cron-apt" package in the repos:
          Contains a tool that is run by a cron job at regular intervals. By default it
          just updates the package list and downloads new packages without installing.
          You can instruct it to run anything that you can do with apt-get
          (or aptitude).
          File list:
          cron-apt: /etc/cron-apt/action.d/0-update
          cron-apt: /etc/cron-apt/action.d/3-download
          cron-apt: /etc/cron-apt/config
          cron-apt: /etc/cron.d/cron-apt
          cron-apt: /etc/logrotate.d/cron-apt
          cron-apt: /usr/sbin/cron-apt
          cron-apt: /usr/share/cron-apt/functions
          cron-apt: /usr/share/doc/cron-apt/README.gz
          cron-apt: /usr/share/doc/cron-apt/changelog.gz
          cron-apt: /usr/share/doc/cron-apt/copyright
          cron-apt: /usr/share/doc/cron-apt/examples/0-update
          cron-apt: /usr/share/doc/cron-apt/examples/3-download
          cron-apt: /usr/share/doc/cron-apt/examples/9-notify
          cron-apt: /usr/share/doc/cron-apt/examples/config
          cron-apt: /usr/share/man/fr/man8/cron-apt.8.gz
          cron-apt: /usr/share/man/man8/cron-apt.8.gz
          Last edited by kubicle; Jan 08, 2014, 10:18 AM.

          Comment


            #6
            Thanks guys, I really appreciate all the help, and patience. I am writing all of this down so next time I'll know what to do.

            Comment

            Working...
            X