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

    Question Crontab problem on raspberry pi

    - I' dlike to execute a python script at reboot on my pi.

    below are the steps i took but not happened:

    -sudo crontab -e
    -add atreboot python /home/Documents/pi/python/
    -save file
    -check with ps aux or top but cant see anything happening

    where can i check if the line is added to cron ?
    what can i do to fix this?

    * (at in atreboot is actually ampersand but i cant use it here)

  2. #2
    Linux Engineer
    Join Date
    Jan 2005
    Saint Paul, MN
    crontab -l
    is use to "list" your current contab.

    I assume that the entry looks like:
    @reboot        python /home/Documents/pi/python/
    And not
    atreboot        python /home/Documents/pi/python/
    Also cron uses these files (when they exist):
    And some distros require that the user (in your case root) be a member of the group cron and/or crontab as well.

  3. #3
    my also writes data to a text file in the same directory as the script ,
    and its causing problems when i use crontab to launch it.

    How can i change the current working directory for the script to run
    at reboot by crontab service ?

    or is there some other solution?

  4. $spacer_open
  5. #4
    Linux Engineer
    Join Date
    Jan 2005
    Saint Paul, MN
    1) Change the script to except the directory as an argument and have it CD into it.
    2) Change the command in the "crontab" so it changes directories by prepending in the command with "CD somepath && " (I have not tried this as I do option 1). Such as:
    @reboot        cd /tmp && python /home/Documents/pi/python/

Posting Permissions

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