cron troubles

This is a discussion on cron troubles within the Linux Programming forums, part of the Platform Specific Boards category; So I am trying to run a script on start up every minute. I have added the bash script to ...

  1. #1
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302

    cron troubles

    So I am trying to run a script on start up every minute. I have added the bash script to my /etc/init.d/ directory and updated my rc.d file with the update command and used the defualts. So in order to run the script every minute I am attempting to use crontab. I opened crontab with sudo crontab -e and entered * * * * * sh /path/to/script.sh and it does not work. Google shows a lot of people have this same issue but I cannot seem to find a solution. Mostly suggestions. What am I doing wrong? Is there an easier approach?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    How much of the manual page have you read?

    I see a couple of choice comments which deserve further work for you.
    If the /etc/cron.allow file exists, then you must be listed therein in order to be allowed to use this command. If the /etc/cron.allow file does not
    exist but the /etc/cron.deny file does exist, then you must not be listed in the /etc/cron.deny file in order to use this command. If neither of
    these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users
    will be able to use this command. For standard Debian systems, all users may use this command.
    ...
    BUGS
    Although cron requires that each entry in a crontab end in a newline character, neither the crontab command nor the cron daemon will detect this
    error. Instead, the crontab will appear to load normally. However, the command will never run. The best choice is to ensure that your crontab has a
    blank line at the end.
    Also, check the cron daemon is actually configured to run on your system
    Code:
    $ ps -A | grep cron
     1169 ?        00:00:00 cron
    Also, does your script rely on the full set of environment variables (like $PATH) to be setup?
    The environment that cron provides to your script is positively spartan compared to what you get at your bash prompt.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    I couldn't figure out how to get cron to run so i am using watch.

    sudo apt-get install screen
    screen watch -n 60 /path/to/script.sh

    The cron daemon isn't automatically ran on startup. i use pgrep to find if there is a running cron daemon but none are found. My solution is working. I only need to manually run it the first time. Thanks Salem!

  4. #4
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Then to run it i the background hit control + a then control + d

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,516
    Why not just make crond start at boot: Linux Start Restart and Stop The Cron or Crond Service.

  6. #6
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Quote Originally Posted by anduril462 View Post
    Why not just make crond start at boot: Linux Start Restart and Stop The Cron or Crond Service.
    For one, cron is not running on start up. Two, I cannot find anything with the name crond on my system. No daemon is even present. Even when i manually start cron, my programs won't work anyway. So, why mess with cron and frustrate myself, when what i am doing is already working??

    BTW, I read that page prior to this post. Along with many others.

  7. #7
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,516
    My apologies, cron is the daemon. Many daemons have the 'd' as a suffix to signify they are the daemon, I typed it as a reflex.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin.get() Troubles
    By yukapuka in forum C++ Programming
    Replies: 19
    Last Post: 06-04-2008, 01:30 PM
  2. creating cron job
    By nitinmhetre in forum Tech Board
    Replies: 3
    Last Post: 12-29-2006, 09:16 AM
  3. NIC Troubles?
    By Bajanine in forum Tech Board
    Replies: 4
    Last Post: 05-16-2004, 04:45 PM
  4. Cron - for all you unix people
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-03-2004, 10:52 PM
  5. having troubles
    By neandrake in forum C++ Programming
    Replies: 7
    Last Post: 03-07-2002, 08:31 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21