Page 2 of 20 FirstFirst 123412 ... LastLast
Results 11 to 20 of 191

Thread: How-to for crontab

  1. #11
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    Re: How-to for crontab

    Quote Originally Posted by evs
    KDE has a program called KCron which does the trick, but I don't know if there's anything like it for Gnome.
    Thanks for your reply, but that is not what I meant. I do not need a GUI tool for crontab or to create cron jobs (there are also a few for gnome), but I need cron to run GUI applications, like a music player or whatever. Thanks, anyway.

  2. #12
    Join Date
    Jun 2005
    Beans
    33
    Distro
    Kubuntu 6.10 Edgy

    Re: How-to for crontab

    Oh ok, sorry I can't help you with that. But I would be interested to find out how to do that as well.

  3. #13
    Join Date
    Jul 2005
    Beans
    1

    Re: How-to for crontab

    Would someone be interested in writing "Anacron HowTo", so we can have complete scheduling howto for Ubuntu?

  4. #14
    Join Date
    Sep 2005
    Location
    Cedar Rapids, IA, USA
    Beans
    545
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: How-to for crontab

    It didn't occur to me to use the export EDITOR=vi to get crontab -e to use vi. Must have been a brain fart when making my crons, since I have never done them until recently.

    Thanks for the info.
    #399784 | Ubuntu User #287
    *** If you're going to program, install the damn build-essential package ***
    There is no such thing as Ubuntu specific programming
    Save the electrons - if you quote, trim!

  5. #15
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    Re: How-to for crontab

    First, an explanation: this was meant to be a separate howto, but for some reason unknown to me, my thread didn't showed up.

    To learn more about crontab, please refer to the parent post of this thread.

    My motivation to find this out was because there are several radio shows I really like and I was always missing them. As such, I needed something to start amarok playing the chosen radio station at specific times. Probably this could be achieved through a more elegant solution, but this serves its purposes. Also, I knew that by learning how to do this, I could use it for many other things.

    To accomplish this, you have to edit your crontab:

    Code:
    crontab -e
    you can also use a nicer GUI tool to edit crontab, like Gnome Schedule (not in the repositories) or KCron (available on the repositories).

    If you use a GUI tool, please adapt the instructions accordingly. I will explain this using as basis the default crontab editor.

    To run a GUI command on cron, you'll have to tell cron what display the program should use. For that you use:

    Code:
    export DISPLAY=:0
    :0 is the default. If you like the program to run on other display, please change the number accordingly (e.g. :1, :2, etc).

    So, you add to what is explained here:

    Code:
    01 04 * * * /usr/bin/somedirectory/somecommand
    the export variable, like this:

    Code:
    01 04 * * * export DISPLAY=:0 && /usr/bin/somedirectory/somecommand
    So, in my case, as I want amarok to play Antena2 (radio station) at a specific time, I use:

    Code:
    30 16 * * 7     export DISPLAY=:0 && amarok mms://rdp.oninet.pt/antena2
    This will make amarok start the Antena2 url every Sunday, at 16:30. But I want also to shut up amarok after the show is finished. So, I use:

    Code:
    0 17 * * 7     export DISPLAY=:0 && amarok -s
    This will shut up amarok at 17:00 every Sunday.

    You can use this export trick to the limits of your imagination with every kind of application you want.

    Another example that occurs me is for file sharing and when your greedy ISPs only allows you a low monthly download limit, but have some kind of free download period (normally very late at night - this is the case of my ISP 8)). As such, I need to start nicotine (soulseek network application) only during that free period (3AM - 9AM). So, I use:

    Code:
    0 3 * * * export DISPLAY=:0 && nicotine
    that will start nicotine everyday at 3AM. To shut it down, I use:

    Code:
    0 9 * * * killall nicotine
    This will shut it down at 9AM.

    Hope this helps some of you.

    ps: I posted this here as it is related with the subject matter and to answer evs.

    ps2: If one of the admins gets to see this, please find out what happened to my thread. I'm just wondering, because my browser looks kind of overbuggy lately (too many extensions ) and I don't even know if it was sent in the first place. Thanks a lot.

  6. #16
    Join Date
    Oct 2005
    Location
    Peru, South America
    Beans
    1,486
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How-to for crontab

    very informative, and nice howto on crontab's. Thanks.
    Code:
    30 23 05 * * tar cvpzf /home/shane/storage/homebackup.tgz --exclude=/Portable --exclude=/storage 
    --exclude=/Pictures
    Here is a simple backup crontab that I have added to mine. My question is how can I get this to do this for root, as root? Thanks. Or do I need to add this here:
    Code:
    crontab -u root -e
    and then add my backup for my file system? Thanks.

    Shane

  7. #17
    Join Date
    Feb 2006
    Location
    USA
    Beans
    98

    Re: How-to for crontab

    shane2peru - I believe you log in as the root user, then set the crontab.

    Or better yet, use the "su" command.

    First, set a password for root:
    Code:
    sudo passwd root
    Then become root:
    Code:
    su
    Then issue your crontab commands as per above tutorial.

  8. #18
    Join Date
    Oct 2005
    Location
    Peru, South America
    Beans
    1,486
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Post Re: How-to for crontab

    Oh, my bad, the real command I was using is:
    Code:
    sudo crontab -u root -e
    Also I did get the logs to work. Unfortunately, there was some problem with my tar, and I tried to restore a backup file, and very much messed things up so I had to re-install.

    Shane

  9. #19
    Join Date
    Feb 2007
    Location
    Brampton, Ontario
    Beans
    883

    Re: How-to for crontab

    How could I get cron to run weighttraninglog.xls every night at 11pm? I don't know what the command is to run an .xls file, which is associated with OpenOffice for me and works fine of course, just don't know the terminal command. Anyone ??

  10. #20
    Join Date
    Jan 2007
    Beans
    4

    Re: How-to for crontab

    To open an xls file on a schedule just requires a synthesis of what's been put in this thread so far. The only piece of missing info is the command for openoffice calc (like excel). That command is "oocalc". To open a file using oocalc from the command-line is just

    Code:
    oocalc /path/to/file.xls
    To get a job to do this on a schedule just create a cron job to perform following command on the schedule you wish. The command(s) you need is/are:

    Code:
    export DISPLAY=:0 && oocalc /path/to/file.xls
    This cron job line should do what you want to do (adjust path to your excel file as necessary)

    Code:
    00 23 * * * export DISPLAY=:0 && /usr/bin/oocalc /path/to/weigttraininglog.xls
    Hope that helps!
    Last edited by pidgas; April 1st, 2007 at 03:23 AM. Reason: add specific cron job to do what was requested

Page 2 of 20 FirstFirst 123412 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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