Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-06-17 03:53:01

Akadole1932
Member
Registered: 2021-05-28
Posts: 10

Cron job error

I created a cronjob using the crontab -e command
00 * * * * xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS1/workspace0/last-image -s /home/Aryan/MyDrive/Stuff/Wallpapers/xfce-dynamic-wallpaper/src/backgrounds/$(date +%H).jpg.
This command checks the hour and sets the wallpaper accordingly from a folder with 24 pictures(named as 00 to 23).The command runs perfectly fine in a terminal window but not as a cron job.
Also the cron package works fine as i have done many cron jobs.
(I run MX linux 19.4 with kernal version 4.19.0-16-amd64 if it helps)

Last edited by Akadole1932 (2021-06-17 03:53:46)

Offline

#2 2021-06-17 05:42:58

PaperNick
Member
Registered: 2013-05-26
Posts: 107

Re: Cron job error

Hi there! The problem is that the % sign in crontab is treated as new line separator.
Here's the explanation from the crontab manual page:

Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. There is no way to split a single command line onto multiple lines, like the shell's trailing "\".

So the working version of your command would look like this:

00 * * * * xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS1/workspace0/last-image -s /home/Aryan/MyDrive/Stuff/Wallpapers/xfce-dynamic-wallpaper/src/backgrounds/$(date +\%H).jpg

Sources used:
https://serverfault.com/questions/27447 … ns-in-cron

Offline

#3 2021-06-17 11:05:07

Akadole1932
Member
Registered: 2021-05-28
Posts: 10

Re: Cron job error

Thanks for the advice It's working now!!! .
I did that still it didn't work so i redirected the output to a text file and this was the output - Failed to init libxfconf: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 (previously i had not output). So i did a quick search and got an answer https://askubuntu.com/a/805797 here.And it works!
Thanks for the answer, now I have a different wallpaper based on the time of day <3 smile

Last edited by Akadole1932 (2021-06-17 11:32:29)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 9 queries executed - Memory usage: 522.79 KiB (Peak: 523.63 KiB) ]