I'm using a RaspberryPi with standard Raspbian.
Currently I'm working on some sort of weather station.
For now I have three python scripts - one which is updating txt files for website - update1m.py ( it will not be necessary in few next days so I'll delete it) , second one for updating mysql datebase with measurement - updateDB.py and the last ( this one is generating problem ) for generating chart out of measurements gathered in database.
I'm a beginner so propably my methods are as dumb as it is possible but this is the reason why I'm asking you for help.
Via command line im running - sudo crontab -e.
My crontab looks like this:
First two scripts are running properly after reboot and every minute.
Unfortunatelly last one imag.py is not running with cron. It is working properly if I simply execute it with python ./imag.py but not with cron.
I'm sure that path for script is ok.
As it is, no, but i am astonished that even the other scripts work. cronjobs are usually started from "init" (process number 0) and the environment of init is usually empty, especially the variable PATH is not set. This means that "python" should not work, only "/some/path/to/python". Find out where the python executable is by calling:
(depending on your shell you might replace "which" with "whence" or "whereis") and put the displayed path in the cron call, like this (analoguously for the other entries):
For the same reasons there could be other environment contents which the script is missing when being called from cron. Enter "set" at the command prompt to display the whole environment of your shell to find out. You will have to set them in the script in this case.
I dont't think that it was the problem cause in python scripts I have #!/usr/bin/python
at start.
Happily I found the bug - in my python script I had a part:
- read database table length from external file. This file was located in home/pi/meteo so in the same place as imag.py script - but from cron the path for file couldn't be found. I changed this part of python script to -
and now everything works fine.
Several environment variables are set up automatically by the cron(8) daemon. SHELL is
set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's
owner. PATH is set to "/usr/bin:/bin". HOME, SHELL, and PATH may be overridden by set-
tings in the crontab; LOGNAME is the user that the job is running from, and may not be
changed.
(I've no idea if that's the case on Raspberry though. Or on reboot, for that matter...)
I have python installed here on windows:
C:\Python27 and can run a script from the command line but would rather use cygwin.
$ cd "C:\Users\cmccabe\Desktop\annovar"
cmccabe@DTV-L2231M5J /cygdrive/c/Users/cmccabe/Desktop/annovar
$ python run_batch_job.py
Traceback (most recent call last):... (3 Replies)
Hi guys!
I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem).
Here is my script:
bash-3.00# cat /bk_tool/backup2.sh
#!/usr/bin/csh
clear
set DIR_HOST='SCP08'
... (3 Replies)
I am facing an issue where sometimes crontab is running script with some delay.
Below is the stmt in script and it is the only stmt in script.
echo "running at `date` " >> CRONCHECK.log
Below is the cron entry.
0 11 * * * CRONCHECK.sh
Below is the time of run each day.
running at Fri... (8 Replies)
Hi All,
I am having the below script to be run from crontab, it it doesnt run.
1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt
when i run i manally it runs without any issues.
Could please help me as to why doesnt it run the script.:( (7 Replies)
Hi,
I have created the below script,
set -x
# Set the Path of Environment file
ENV_FILE_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin
LOG_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/log
export ENV_FILE_DIR
export LOG_DIR
# Set Audit Environment
. ${ENV_FILE_DIR}/QDM.env... (8 Replies)
Hi, I posted this in the Solaris forum but I think this one would be more appropriate.
I created a script starting with the following lines:
#!/usr/bin/ksh
flag=n
export flag
typeset -i quant=0
(...)
When running it I'm getting the following 2 errors:
/tmp/tstscript/testfail.ksh:... (9 Replies)
Any idea how I can run a program from a phyton script?
For example, in csh I will do
$tpath/tsimplex base=$fbase data=$fdata restore=$frestore \
nxp=$nx nzp=$nz param=$param intp=$intp nlay=$nlay \
varp=$varp sigma0=$sigma maxiter=$maxiter tol=$tol \
... (2 Replies)
Hi,
I'm trying the backup a few information commands of my Check Point FW (it's on a SPLAT linux machine). This is the script I wrote:
#!/bin/bash
cd /var/tmp/
file1=netstat_`/bin/date +%d%m%y`.txt
file2=ifconfig_`/bin/date +%d%m%y`.txt
file3=cpstatos_`/bin/date +%d%m%y`.txt... (2 Replies)
Hi all,
I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like:
ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory
/tmp/file.sh: line 5: 8304 Killed ... (4 Replies)
Hi,
I made this script for TRU Unix 5.1 OS based Node.
When the script was run manually all the commands were running properly. But when it was run from Crontab, one command is not running.
This command is not running when the script is running from Crontab:
#... (2 Replies)