I want to do the following:

Use my raspberry pi as a smart display, kind off like what the Chromecast does when it's not streaming anything. I also want it to turn on and off at certain times, like turn on 8am and turn off 10pm or something like that.

The problem is, that I struggle with turning it on or off. Since the raspberry pi doesn't have a real-time clock and I don't want to attach an extra circuit, I tried to only turn off my display with Cec-Client or vcgencmd. To run the command on a specific time, I tried to run it with cron.

The command was then the following:

0 8 * * * echo "on 0" | /usr/bin/cec-client -s

(also tried some little variations off it)

But nothing ever happens.

Can somebody please help me out, I'm open for completely different solutions if you happen to have a better one.

  • 1
    Break the problem down: which part of this isn't working? What happens if you send the cec command manually, without using the cron? Does it work? Experiment until that works. Then, what happens if you put a different command in the cron, which you know should work and which you can easily see has run (such as touch /home/pi/test)? Experiment until that works. Then tie the two together. – Mark Smith Apr 9 '19 at 9:39

@MarkSmith made a good suggestion. To help your troubleshooting, ask cron to redirect its error messages (stderr) to a file so that you can see it:

0 8 * * * echo "on 0" | /usr/bin/cec-client -s >> /home/pi/cronjoblog 2>&1 

Assuming that you are logged in as user pi, this will put any error message generated in the file cronjoblog in your home directory. Actually, the >> will append the output to the end of the file, so if you run this several times, the error messages will be added to the end of the file. If you want to overwrite the file instead of append, replace the >> with >

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.