Find the answer to your Linux question:
Results 1 to 9 of 9
For some reason I can not get cron to execute scheduled tasks I edited crontab using crontab -e; right after doing that i checked it with crontab -l and was ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Location
    LA/Berkeley
    Posts
    33

    [SOLVED] Help with Cron


    For some reason I can not get cron to execute scheduled tasks

    I edited crontab using crontab -e; right after doing that i checked it with crontab -l and was shown:

    # m h dom mon dow command
    * * * * * /usr/bin/my_script
    #


    If I have that correctly, that should execute that my_script every minute (I set it to that so that I could see if any changes I made ended up working without waiting to long). I then tried restarting cron (/etc/init.d/cron restart) and my script won't execute at all. I know the script works, because when I try to execute it on its own, it works fine.

    I can't think of any other reason why it wouldn't work, does anyone have any ideas why my cron isn't working as expected?

  2. #2
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108
    it should be

    */1 * * * * /usr/bin/my_script

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Location
    LA/Berkeley
    Posts
    33
    Thanks for your response

    I do not think that is the problem; earlier I had

    30 1 * * * /usr/bin/my_script


    and the script failed to execute at 1:30 am; i also tried your suggestion (starting with */1) and still, the script has not executed.
    I was thinking the problem may be with cron being executed somehow, or the location of my crontab, or something. As far as i can tell, my crontab syntax itself is all right.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie Geeth's Avatar
    Join Date
    Apr 2008
    Location
    Brisbane Aus
    Posts
    176
    What are you trying to get cron to run?
    Is it a program? Or something like moving files from one place to another?

  6. #5
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108
    crontab wont print output on ttys, but still it will run and send a mail,
    check your mail, by using mail or mutt command..if u get mails from crondaemon, it means that your script is running.
    and ensure that your script is running normally, it have executing permission.

  7. #6
    Just Joined!
    Join Date
    Feb 2007
    Location
    LA/Berkeley
    Posts
    33
    It's just a little script consisting of a zenity prompt and a kill command;
    it's nothing too complicated, but I was using it mostly as a way to test out cron.

    The script itself runs fine when i run it from the terminal: the prompt comes up and when i select yes the process in question is killed.

    As far as the permissions, the file itself has all the permissions necessary to run, is there some different problem with permissions when cron is running the script?

  8. #7
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108
    have you checked system mail?

  9. #8
    Just Joined!
    Join Date
    Feb 2007
    Location
    LA/Berkeley
    Posts
    33
    Thanks for the suggestion, i checked the system mail and there was a message from crondaemon saying:

    (zenity:21956): Gtk-WARNING **: cannot open display:


    Earlier everything i had tried to use with cron involved UIs, when i tried a simple command, it worked fine. I'm glad I at least know what the problem is now

    Is there any way to get cron to work with commands involving UIs?

  10. #9
    Just Joined!
    Join Date
    Feb 2007
    Location
    LA/Berkeley
    Posts
    33
    Alrighty; I looked around a bit for solutions on the Internet and added

    export DISPLAY=:0.0

    before my script in the command in my crontab, and now my script works perfectly, UI and all

    Thanks very much for your help

Posting Permissions

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