I set up two cron tasks to mute my desktop's audio at night and then unmute it in the morning (so that emails and other notifications don't wake me up):lumpy@cheetoserver:~$ crontab -e# At 10:15 PM every night, mute the volume15 22 * * * /usr/bin/amixer -q set Master mute# At 7AM every morning, unmute the volume0 7 * * * /usr/bin/amixer -q set Master unmuteThe audio is muted at night, but never gets unmuted in the morning. Yet if I simply execute the 7AM unmute command in the shell:/usr/bin/amixer -q set Master unmute...the audio is unmuted immediately.I tested both commands before entering them into crontab, and they mute and unmute immediately (i.e, it doesn't take two unmutes to counteract a single mute, or anything like that).Can anyone shed light on why this isn't working?
cron task to unmute my audio isn't working
linux;debian;cron
I found other posts by people having exactly the same issue. The problem seems to be that the cron job runs without the necessary context, and adding export DISPLAY=:0 to each task is the solution:lumpy@cheetoserver:~$ crontab -e# At 10:15 PM every night, mute the volume15 22 * * * export DISPLAY=:0 && /usr/bin/amixer -q set Master mute# At 7AM every morning, unmute the volume0 7 * * * export DISPLAY=:0 && /usr/bin/amixer -q set Master unmuteFor the sake of completeness, I'll add that several solutions mentioned changing set Master in the two tasks above to set Master playback. This made no difference in my case, but if the first solution doesn't resolve your problem, you may want to try this.