Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
Like Tree1Likes
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2014
    Posts
    13

    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 Engineer
    Join Date
    Dec 2013
    Posts
    1,188
    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
    Just Joined!
    Join Date
    May 2014
    Posts
    13
    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. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,188
    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?

  5. #5
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,188
    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.

  6. #6
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,188
    Have you looked in syslog to see if there are any errors?

  7. #7
    Just Joined!
    Join Date
    May 2014
    Posts
    13
    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.

  8. #8
    Just Joined!
    Join Date
    May 2014
    Posts
    13
    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

  9. #9
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    889
    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.

  10. #10
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,188
    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.

Page 1 of 2 1 2 LastLast

Posting Permissions

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