Hello All,
I have been struggling for days now to get my digitemp cron job
working and am I close to resigning... but perhaps I can find some
help here?
What I want to do is run a cron job to log digitemp temperature
readings from a USB 1-wire adapter into log files (one file every 24
hours).
The script to do this looks like this:
hartmut@iboga:~$ cat /home/hartmut/bin/run_1d_temp_log
#!/bin/sh
log_path=/home/hartmut/
log_filename=$(date +%Y_%m%d_%a_%H%M)
log_target=$log_path$log_filename.log
digitemp_DS2490 -a -o2 -d 30 -n 2 > $log_target
and here is my crontab:
hartmut@iboga:~$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --
report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --
report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --
report /etc/cron.monthly )
#
*/2 * * * * root /home/hartmut/bin/run_1d_temp_log >> /home/hartmut/
cron.log 2>&1
When I run the run_1d_temp_log script from a terminal with
sudo sh /home/hartmut/bin/run_1d_temp_log
then I will get a log file with the desired temperature readings,
like...
DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 -
http://www.digitemp.com
Found DS2490 device #1 at 002/003
0 43.81 28.88 43.94 30.94 21.81 25.06 30.81 23.75 41.19 24.56 47.31
25.75 35.25 26.69
30 43.81 28.88 43.88 30.88 21.81 25.06 30.81 23.75 41.06 24.69 47.25
25.75 35.25 26.56
The logs created by the cron job however have the temperature readings
missing, they only show the copyright note and the time stamps,
like...
DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 -
http://www.digitemp.com
Found DS2490 device #1 at 002/003
0
30
The error log that I use in crontab is empty. So I have no clue really
were to start looking.
When googling about this problem I noticed that other people never use
sudo to run their scripts and that they use the user crontab instead
of the system wide cron table. However, they also seem to have the 1-
wire/serial port interface rather than the USB version that I am
working with. Anyway, when I run the script without sudo I get this
message:
hartmut@iboga:~$ sh /home/hartmut/bin/run_1d_temp_log
USB ERROR: Failed to set configuration
and since it is working fine with sudo I thought I set up a job in the
system cron table.
Has anyone any ideas how to investigate this further or perhaps a
solution?
bye,
Hardy