My crontab is like as follows (I am trying to change my GNOME theme)
crontab -l
0 5 * * * /usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adapta'
30 21 * * * /usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adapta-Nokto'
Also, I created this file
echo $USER
nikhil
cat /etc/cron.allow
nikhil
When I run the command as mentioned in crontab, both of those work.
Could you please tell if I missed out some step?
Edit:
I created a script file, which I execute with cron:
export TERM=xterm-256color
TimeHr=$(date +%H)
if ((${TimeHr}>18 || ${TimeHr}<5)); then
#if [${TimeHr} -gt 11 || ${TimeHr} -lt 5]; then
mkdir ${HOME}/Documents/TestNight
/usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adapta'
else
mkdir ${HOME}/Documents/TestDay
/usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adapta-Nokto'
fi
This is crontab
$ crontab -l
36 5,19,23 * * * bash /home/nikhil/GnomeThemeChange
@reboot bash /home/nikhil/GnomeThemeChange
cron
does work as it is able to create Test Folders. But, what should I do to run gsettings
inside cron?
Are you sure cron is not working? If you add a line like
to your crontab, then does the file appear in
/tmp
?If that file won't appear after a minute or so, then
or
If cron is not running, then try to start it with
But I guess the problem with your command above is, that
gsettings
needs to have its environment set up correctly in order to run, which it probably does not have, when run fromcron
.Thanks to Tomáš Pospíšek for the suggestions.
Add the following to the script: