Results 1 to 4 of 4

Thread: Setting up cron to do work

  1. #1

    Default Setting up cron to do work

    Hello! I have Leap 42.2 (for now) soon to be upgrading to 42.3. But before doing that I want to have cron do some work for me. In looking at some man pages I can't edit the daily file directly and have to use a program like KCron. When I try to run it I get a command not found. I've tried it while in super user mode, tried at by the command kcron, and tried to find it trough the application launcher and applications to no success. So what is one to do?

    By the way the cron service was running.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,003

    Default Re: Setting up cron to do work

    When you want to create a crontab entry for you as end-user, use
    Code:
    crontab -e
    For that you have to know what to do there and that can be found with
    Code:
    man 5 crontab
    When you use a Desktop Environment (you did not tell us much about what you do or why you think you need cron), there might be a GUI for managing your crontab (well, I searched for the KDE one, but could not find it, maybe it is dropped).
    Do not try to edit such a crontab with an editor, but use the crontab tool.

    When you want to manage crontab on the system level, there is first the same as for every user, but for user root (again use the crontab tool).
    Then there is the system crontab at /etc/crontab. You will normally find already one entry there and that entry sees that a set of entries in the following directories is run on a regular base: /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.montly. These can be edited by your preferred editor.

    A few warnings though.
    Things (scripts, programs) started from cron run in the background and have thus NO connection to any GUI that might be running or not. Some people seem to think that these scripts/programs can open windows on their screen. That is not the case.

    These scripts/programs run in a different environment then when they are started from a shell in the CLI. Thus take care about any assumptions you may have about environment variables, etc. that may or may not have the values you assume they will have. See the man page mentioned above.

    There is no terminal connected to what is running in the background, thus standard and error output must go somewhere. E.g. by redirecting them to a log file or to /dev/null.

    In short, some basic knowledge about shell (scripting) might be needed to understand how cron is working.
    Henk van Velden

  3. #3
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default Re: Setting up cron to do work

    Here's what I do to use cron, it lets me edit the file directly, it might be of interest.

    I like to have a fairly modern editor for cron. So I install leafpad
    Code:
    zypper in leafpad
    Then I create a global responder for editing crontab by creating a file named profile.local and placing that file in the directory /etc. To reiterate I make the file /etc/profile.local

    I put this line in the file profile.local:
    Code:
    export EDITOR=/usr/bin/leafpad
    Then I reboot and all is ready.

    After the reboot one can run this command to access the personal crontable:
    Code:
    crontab -e
    Or if you open a console and change to su and run the command, you have access to the root crontable

    Be careful to leave a blank line at the bottom of the crontable

    FWIW
    Last edited by swerdna; 31-Jul-2017 at 02:02.
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

  4. #4

    Default Re: Setting up cron to do work

    Thank you all for the responses! After your messages it was coming back to me as I had used it before a long time ago. The reason for using cron is for updating the awstats for some web sites.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •