New answers tagged

1

What command do you set in your crontab file? Is the script intended to run once and done or constantly post power readings? As you mention, crons can fail because of path issues. Not only for the script but also for python if that is how you are running the script. For example: @reboot /usr/bin/python3 /home/pi/example.py You may wish to save the output of ...


0

using the above system md may just need a little tweak if your python script uses paho.mqtt installed as python3 version ExecStart=/usr/bin/python /home/user/project/MQTTclientscript.py to ExecStart=/usr/bin/python3 /home/user/project/MQTTclientscript.py


1

It's been a while since I've used raspistill, but this may work as a cron job: Create your bash script at /home/pi/camera.sh as follows: #!/bin/bash DATE=$(date +"%Y-%m-%d_%H%M") /usr/bin/raspistill -o /home/pi/camera/$DATE.jpg Be sure to mark it as executable : chmod a+x /home/pi/camera.sh Add the following line to your crontab (crontab -e): * * ...


0

You can create a service to run shell script, instead of @reboot in crontab. Like this https://github.com/mohdismailj/fancontrol/blob/main/fancontrol.service


0

This line in your script: cd "$(/home/pi "$0")"; is trying to execute /home/pi as if it's a program, but it's surely a directory. What did you mean this line to be?


1

Since you are using stdio, a fifo might be a solution for your input. For example, open two terminals and do: terminal 1: |terminal 2: $ mkfifo fifo | $ tail -f fifo | sed 's/a/A/' |$ echo hoppa > fifo hoppA | So, you could create a fifo in your ...


1

If you want it to keep a process running so you can use it then install the screen program then use screen at the start command in the cron job. This is where you use the /usr/bin/screen -d -m -fa -S Screen_Name_For_Instance /usr/bin/name_of_server_program to start it up. You can test the command at your command line. Once happy it runs correctly then the ...


0

As you have to with cron if you had put a PATH= in your script it would have found the files. Cron does not inherit any PATH or other environment variables they need to be set or you use absolute paths to the files, as you discovered.


1

I found the problem. Actually I was referring to some folders (the one where the files to upload are) with relative paths. It works when I run the script directly with python command, but not with Cron. So I updated all the paths with absolute values, and now it works :)


Top 50 recent answers are included