In the crontab -u pi -e of my digital picture frame I have got two processes.

The first one calls feh on reboot and starts a slide show.

@reboot bash /home/pi/ledslide1.sh >> /home/pi/logs/slidelog 2&>1

And then other instances should be started at certain times.

15 8 * * * bash /home/pi/ledslide2.sh >> /home/pi/logs/slidelog 2&>1
15 9 * * * bash /home/pi/ledslide3.sh >> /home/pi/logs/slidelog 2&>1

But the feh slide show is running on repeat. That way I have to kill the process first right? timeout is not working, because I don’t know when the reboot takes place?

  • You would have to alter your scripts to save a PID (process ID) to a file. And then have other scripts check if that PID by killing the older PID or whatever else you feel would need to be done. – Giacomo1968 Sep 13 '15 at 17:30
  • 1
    Thank you @JakeGould. Your comment gave me the idea for my answer (see below). – Markus Sep 13 '15 at 18:48
  • Happy to have helped! – Giacomo1968 Sep 13 '15 at 20:51

In your ledslide.sh scripts, just use pkill -9 feh to kill feh. No need to keep track of PIDs or anything. pkill is used to search for and kill processes with a given name. I suggesting reading the manpage for pkill and pgrep.

  • I did put this command in the crontab. But it is more or less the same? – Markus Sep 13 '15 at 18:50
  • Yeah this would work. But what if there is more than one instance of running? A PID would ensure only the feh connected to the PID would be affected. Might seem like a minor concern but worth mentioning. – Giacomo1968 Sep 13 '15 at 19:03
  • Yes, thank you. I will take that into account. – Markus Sep 13 '15 at 21:34

This has worked for me so far:

@reboot bash /home/pi/ledslide1.sh >> /home/pi/logs/slidelog 2&>1
15 8 * * * pkill -9 feh && bash /home/pi/ledslide2.sh >> /home/pi/logs/slidelog 2&>1

The .sh file invokes feh and puts it into the background. pkill -9 [KEYWORD] closes the feh process.

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.