6/7/2023 0 Comments Cron job to copy log files![]() That’s why nothing went out to your log files - because none of the Python code got executed. The file writing in your script is done via code in your Python script. ![]() So from the cron perspective the file will just run and fail. And then it will just crash out because the Python syntax will cause bash to throw syntax errors, or command unknown type error messages. So if your default shell is bash, it will run in bash, if it’s zsh, it will run in zsh.īecause your script is a Python script, running it as a cron job without somehow specifying that the script requires the Python interpreter will result in the shell running the Python script as a bash script. Without specifying the path in cron and without a shebang, the shell will assume the script is written in its own language. That way you wouldn’t need to specify the path to the interpreter in cron. The shebang must be the very first line in the file, before the imports! That tells the shell which interpreter to load, in order to run the script. Please let me know if you need any other info. I run the cron job as: python3 /home/pi/Desktop/sensor_data.py I need to just copy and keep adding files, not 'sync', because: 3.When the NVME is full, I can just delete any folder in it to. 2.Setup a cron job on my truenas to copy all the new/modified files in the workstation NVME drive to a pool in the Truenas daily. I run it from the terminal as: $ python3 sensor_data.py 1.Copy new files from SD Cards to my workstations nvme drive, and work with them locally. #Open a file to write the sensor data to. #print("Altitude in ft: %f ft" % alt_in_feet) #print("Pressure: %f Millibars" % pressure) Wfile.write("Altitude in ft: %f ft \n" % alt_in_feet) Wfile.write("Pressure: %f Millibars \n" % pressure) #print("Temperature: %s F" % round(temp_F, 4)) #print("Temperature: %s C" % round(temp, 4)) Wfile.write("Temperature: %s F \n" % round(temp_F, 4)) Wfile.write("Temperature: %s C \n" % round(temp, 4)) Wfile.write("Time Stamp: %s \n" % timeStamp) Temp = sense.get_temperature_from_humidity() #Get the temperature data and write it to the file # Import smtplib for the actual sending function
0 Comments
Leave a Reply. |