Running (and stopping) Impress via cron?

Running Linux on a Pi 3. I launch an Impress presentation via cron at specified times. The presentation loops continually, which is the intended behavior. The cron successfully stops the screensaver and launches the presentation. However, it does not proceed to the next command (sleep for the designated time, before forcefully stopping the presentation). This is because as long as the presentation is running, cron cannot proceed (even if soffice is invoked with a “&” to put it in background).

As a workaround, I’m using a second cron to “pkill” the first. But there surely must be a better way. However, I cannot find a command-line parameter to set the duration of a presentation.

Any suggestions?

Thanks in advance.


Have a look at nohup, disown, …

Perfect, I’d completely forgotten about nohup. It seems to have worked (I was not onsite to verify, but the script logged all steps rather than hanging).

As an aside – This forum platform is odd, I don’t see a need for both “comments” and replies.

Comments are for discussion. Answers are … err… answering your question :slight_smile: They are expected to contain actual (proposed) solution to the problem. So, it’s best to write there the solution, not something like “Answered in the comment above” (please edit it, so that it would be helpful for others having similar problem in the future)

Mike, I would agree–but I can’t control where the answer got posted. PèreOrval provided the answer in a comment (for which I’m grateful), so I attempted to direct others to that answer. That way, my question no longer shows as “unanswered”, and should be sufficient to guide “others having similar problem in the future”, I would think.

The “comment vs. answer” distinction is obviously not particularly intuitive, if we’re having to discuss it here.

If @PèreOrval wants to repost his answer in the intended location, I’ll edit my answer accordingly.

+1 for a well-written question. However, please remove the “Pi for All” link as it does not seem relevant to the question. It belongs in your profile, and I see the link is there as well.

Jim, I removed the link as requested. However, most forums seem to allow links in sigs, as long as users don’t create posts just to promote their sites. It seems a fair tradeoff for contributing (not that my post is a significant contribution, but it will hopefully help someone once it’s answered thoroughly).

As stated in the comment above, by @PèreOrval:

Have a look at nohup, disown, …

Edited / Updated:
My cron invokes a script rather than launching the slideshow directly. Here’s a snippet from my script:

# Launch the slideshow:
  nohup soffice --norestore --view --nologo --display $DISPLAY --show "$SHOW" & \
  echo "$(timestamp) - Sleeping 15 seconds while slideshow starts."  >> $LOG
# Pause for the slideshow to load:
  sleep 15
# Gracefully stop the screensaver:
  echo "$(timestamp) - Stopping the screensaver."                    >> $LOG
  xscreensaver-command -exit

Note that values for $SHOW and $SHOW_LENGTH come from the command line in the crontab. The value for $DISPLAY and $LOG were set earlier in the script. And $(timestamp) is just a custom function that’s much shorter and simpler than typing all the options for the “date” command that I want.

After another sleep (for the duration of the presentation), it restarts and activates the screensaver, then stops the presentation with:

pkill soffice

The reason I launch the presentation BEFORE stopping the screensaver is that the presentation takes 10-15 seconds to load and to go into presentation mode on the Pi. I’d rather not “raise the curtain” until it is running.


Most likely @PèreOrval does not care to post an answer himself. This is not unusual – it only takes a short time to post such a comment, whereas actual answers should generally be complete and better tested. I edited the answer to include the comment’s content, so now you can mark this as the correct answer. However, @PiChef, would you care to expand on this answer somewhat, for the benefit of others who may see this? Perhaps show a few lines from the script that ended up working.

His answer was as complete as I needed, but sure—I can elaborate once I’m at home, on a “real computer“.

I suspect this is “not unusual” in part due to the ambiguity I mentioned above between comments and answers. Thanks for editing.

And for the life of me, I can’t find a button or link to mark the answer as “correct”. I suspect it may be because it appears to be my own answer. That’s one reason I was hoping @PèreOrval would do it. It may also affect his forum karma. Just guessing, as this forum platform is foreign to me.

Yes, it would increase his karma number, but many times for untested ideas I find myself posting comments instead of full-length answers. Anyway, it is possible to mark your own answer as correct. Click on the :heavy_check_mark: on the left side of the answer.

Thanks @jimk. That :heavy_check_mark: is not labeled (at least, not from my iPhone), so I would never have known what it’s for.

On my desktop machine, there is a mouseover tooltip that says “mark this answer as correct (click again to undo).”

@jimk - Unfortunately, “mouseover” isn’t a feature of the iPhone that I’m aware of. :wink: But I’m on my desktop (which is actually a laptop) now. When I hover the cursor over that checkmark, it gives me a tip about marking the answer as “correct”. However, I’m foiled again. I have not earned sufficient points (20) to mark my own answer as “correct”. :frowning:

I upvoted the answer, so you have over 20 points now.

Thanks. Now it’s officially “Answered”.