You are not logged in.
I recently started experiencing crashes, and since I suspect they're heat related, I wrote the following script to monitor hw temperatures, but for some reason the script never writes the result of
nvidia-settings -q gpucoretemp -t
when crond runs it. It works perfectly fine when I run it, and when I run it root though. I've no idea what is going on?
#!/bin/bash
FILE=/home/bladt/core/gputemp
DIR=$(dirname $FILE)
ENTRY_SEP=###########################ENTRY#############################
cd $DIR
cpu=$(sensors)
gpu=$(/usr/bin/nvidia-settings -q gpucoretemp -t)
time=$(date '+%D %T')
echo -e "$ENTRY_SEP \n$time \n$cpu \nnvidia gfx: $gpu \n" >> $FILE
cat $FILE | tail -n1080 > tmp
mv tmp $FILE
What am I missing here?
Last edited by Bladtman242 (2012-07-29 23:33:08)
Offline
I suppose that does make sense.
is there anything I can do about it?
Offline
Wouldn't that mean that root would have trouble, too? (Or did you mean you ran it with sudo?)
I don't know anything about nvidia but perhaps the following might be at least indirectly helpful:
# ref.: http://unix.stackexchange.com/questions/28463/run-a-dbus-program-in-crontab-how-to-know-about-the-session-id
ksession_pid=$(ps -o pid= -C 'kwin -session' | sed 's/ //g')
if [ "$ksession_pid" = "" ]
then
dbus_session_file=~/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-0
if [ -e "$dbus_session_file" ]
then
. "$dbus_session_file"
[ $? == 0 ] || ((allan++))
export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
else
error "Gwall! Allwn i ddim canfod $dbus_session_file."
fi
else
dbus_session_address=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$ksession_pid/environ | sed 's/^DBUS_SESSION_BUS_ADDRESS=//')
[ "$dbus_session_address" != "" ] || error "Could not get DBUS_SESSION_BUS_ADDRESS for session."
export DBUS_SESSION_BUS_ADDRESS="$dbus_session_address"
fi
Last edited by cfr (2012-07-29 22:26:06)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
I meant I ran it with sudo.
Now that I tried running it as root, I get the following:
ERROR: The control display is undefined; please run
`/usr/bin/nvidia-settings --help` for usage information.
Offline
what does the crontab look like? Here is one I have that runs a script to change the wallpaper every ten minutes:
*/10 * * * * DISPLAY=:0.0 /home/dogs/.scripts/random-wallpaper
without the DISPLAY=:0.0 the script ran, but could not change the wallpaper.
Last edited by 2ManyDogs (2012-07-29 22:41:42)
Offline
It looks like this:
# minute hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1.31) (1-12) (0-6)
0-59/2 * * * * /home/bladt/prompt/batlife
0-59/2 * * * * /home/bladt/core/core
I tried using the --display flag and the --config flag (separately) with nvidia-settings, but no luck
Last edited by Bladtman242 (2012-07-29 22:44:35)
Offline
I tried using the --display flag and the --config flag (separately) with nvidia-settings, but no luck
I don't understand this. Did you make a crontab entry with the DISPLAY=:0.0 on it, or just call nvidia-settings with a --display option in the script?
Offline
2ManyDogs: I just called nvidia-settings with the flag, as root.
cfr: Unfortunately, the script ends in the "error "gwall.." branch for me.
EDIT: Aaand success!
Seting DISPLAY in the crontab did the trick.
Thank you all
Not sure I understand why it didn't help as flag for nvidia-settings then, but what the heck
Last edited by Bladtman242 (2012-07-29 23:32:41)
Offline
Glad you got it working. It didn't work with the nvdia flag because jobs run by cron don't have access to X unless you explicitly specify the display in the crontab. That's what falconindy was trying to tell you
Last edited by 2ManyDogs (2012-07-29 23:58:06)
Offline
Huh, it just beats me how setting the exact same variable just before running the command in cron makes a difference?
Offline