I'm running Debian 13 (Trixie) with KDE Plasma 6.3.6, and I'm trying to create a cron job that automatically switches the background of konsole between light and dark modes. Here's what I've written:
`0,15,30,45 18-23 * * * if [[ $(grep "konsoleLight" ~/local/share/konsole/SolarizedLight.colorscheme) ]]; then sed -i "s/konsoleLight/konsoleDark/g" ~/local/share/konsole/SolarizedLight.colorscheme; fi`
`0,15,30,45 8-17 * * * if [[ $(grep "konsoleDark" ~/local/share/konsole/SolarizedLight.colorscheme) ]]; then sed -i "s/konsoleDark/konsoleLight/g" ~/local/share/konsole/SolarizedLight.colorscheme; fi`
The problem is that the sed command doesn't seem to be executing when triggered by cron. When I run the same if statement in an interactive shell, it works fine. I've also confirmed that cron is active using `sudo service crond status` and by creating a simple job that outputs to a file every minute: `* * * * * echo "working" > ~/cron.out`. Why isn't the sed command working in my cron job?
2 Answers
It looks like the issue might be related to using the tilde (~) for your home directory in cron. Cron runs in a different environment, and it may not interpret the tilde as your home path. Try replacing `~` with the full path to your home directory, like `/home/yourusername`. That should help the sed command be executed correctly.
I had a similar issue before! After changing to the full path, make sure that your cron job has the correct permissions to modify the file. Check if the user running the cron job has write access to `~/local/share/konsole/SolarizedLight.colorscheme`. If it doesn't have the right permissions, the sed command won't run.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures