Solved Cron giving me fits

Solved issue
Typically, clock time, and traditionally used for machines that run continuously.

For machines that get powered down, anacron is often used.

You can get an idea of how they work and differ with a search on

difference cron anacron

Wiz

BTW I ain't expert in either, lol.
 


Snap, Stan, our beams crossed.
 
It's working!

I had to use this code in my cron which I found on the web, of course.
Code:
*/5 * * * * env DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /home/dave/Dubai/new/background.sh

However, that didn't take care of the problem. I then ran across a reddit post where someone was having a similar issue. Someone made mention of the fact that there are 2 modes in Linux. Regular and "dark". So, my bash changed to this (last line added)
Code:
#!/bin/bash

min=$(echo "$(date "+%M") - ($(date +%M)%5)" | bc)

test=$(echo "($(date +%M)%5)" | bc)
echo $test
hour=$(echo "$(date "+%H")" | bc)
printf -v min "%02d" $min
printf -v hour "%02d" $hour

name=$(echo $hour":"$min".png")
dir="file:///home/dave/Dubai/new/"
#echo $name
#echo $dir$name

gsettings set org.gnome.desktop.background picture-uri $dir$name
gsettings set org.gnome.desktop.background picture-uri-dark $dir$name

So, after all that, I have a background that changes throughout the day. I used this video to get my 288 still images.

I thank everyone for their input. And I hope someone having similar issues is helped by this thread.
 
Any workaround is a good workaround... well done! :cool:

But I have no clue what you did, nor why that was needed to make it work. It seems to me there should be an easier way than that! But maybe one of our code experts here can break it down for us to understand it better.
 
Any workaround is a good workaround... well done! :cool:

But I have no clue what you did, nor why that was needed to make it work. It seems to me there should be an easier way than that! But maybe one of our code experts here can break it down for us to understand it better.
In basic terms, from what I got out of what I read, is that cron only has built-in access to just a few environmental variables. Thus the env call in the crontab code.

The change in the bash file is due to there being 2 separate modes in Mint (and others). Dark mode and the default. I have mine set to dark. Therefore, I needed the last line in that code and could probably removed the one prior.

If that was any clearer than mud, i hope it helps. Keep in mind, that's how >I< understood it.
 
I may be going about it the hard way or reinventing some wheel, but lately I've been fooling around with running some scripts from cron and I write the scripts to accept a command line option indicating that the script has been called from cron rather than interactively so the script can behave accordingly (load environment variables or whatever) when called from cron. In my setup, it usually doesn't make any difference but I recall (vaguely) at least one instance where running a script from cron was a real pita.
 

Staff online

Members online


Top