Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question Crontab job (python script) does not start


    I entered $sudo crontab -e and added line below

    * * * * * root /usr/bin/python2.7 /home/pi/Documents/python/flashled.py


    The script just flashes a led on the GPIO port
    and needs root priviliges , but it works when i run
    it as a command.

    what could be wrong?

  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    Quote Originally Posted by fbuster View Post
    I entered $sudo crontab -e and added line below

    * * * * * root /usr/bin/python2.7 /home/pi/Documents/python/flashled.py


    The script just flashes a led on the GPIO port
    and needs root priviliges , but it works when i run
    it as a command.

    what could be wrong?
    Not to be facetious but it's doing what you told it to do: never run this command. What are you hoping to accomplish? "man 5 contab" explains the crontab format.

  3. #3
    Are you sure ??
    i investigated the man already and to me
    * * * * * is a valid timing interval for every minute
    i think there must be another problem

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    You could be right - the asterisk does have meaning and according to my manpage: A field may be an asterisk (*), which always stands for ``first-last''.

    I don't see all * given as an example though and in trying to understand the meaning I don't get anything that makes sense. Does it mean to run it once a minute? What does your manpage say?

  6. #5
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    I answered my own question - it does mean run once every minute:

    Code:
    * * * * * date >> /home/gregm/crontest.txt
    Code:
    $ tail -f crontest.txt
    Sat May 10 10:02:01 PDT 2014
    Sat May 10 10:03:01 PDT 2014
    * I see you already answered it.

  7. #6
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    Have you looked in syslog to see if there are any errors?

  8. #7
    its running the script every minute like it should so thats not the problem.

    It should blink a led every minute via the GPIO port.

  9. #8
    I found it : when i removed root from the line it worked.
    I thought you had to add a user for system wide cronjob

    Code:
    * * * * * root /usr/bin/python2.7 /home/pi/Documents/python/flashled.py
    Code:
    * * * * * /usr/bin/python2.7 /home/pi/Documents/python/flashled.py

  10. #9
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    963
    Quote Originally Posted by fbuster View Post
    I found it : when i removed root from the line it worked.
    I thought you had to add a user for system wide cronjob

    Code:
    * * * * * root /usr/bin/python2.7 /home/pi/Documents/python/flashled.py
    Code:
    * * * * * /usr/bin/python2.7 /home/pi/Documents/python/flashled.py
    You only put the user in system crontab files, such as /etc/crontab
    crontab -e is a user's personal crontab, and will always execute with that user's permissions.

  11. #10
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    Possibly an environment issue then? Are you making any assumptions about environment in your script? Perhaps post the script since crontab isn't the issue.

Posting Permissions

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