Ask Your Question

Running (and stopping) Impress via cron?

asked 2017-11-18 23:56:57 +0100

updated 2017-11-21 18:35:53 +0100

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.


edit retag flag offensive close merge delete


Have a look at nohup, disown, ...

PèreOrval gravatar imagePèreOrval ( 2017-11-19 10:47:25 +0100 )edit

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.

Pi Chef gravatar imagePi Chef ( 2017-11-20 06:49:24 +0100 )edit

Comments are for discussion. Answers are .... err... answering your question :) 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 Kaganski gravatar imageMike Kaganski ( 2017-11-20 07:02:32 +0100 )edit

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.

Pi Chef gravatar imagePi Chef ( 2017-11-20 23:13:03 +0100 )edit

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

Pi Chef gravatar imagePi Chef ( 2017-11-20 23:17:08 +0100 )edit

+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 K gravatar imageJim K ( 2017-11-21 00:38:03 +0100 )edit

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).

Pi Chef gravatar imagePi Chef ( 2017-11-21 18:39:33 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-11-20 06:49:57 +0100

updated 2017-11-25 00:41:49 +0100

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.


edit flag offensive delete link more


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, @Pi Chef, 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.

Jim K gravatar imageJim K ( 2017-11-21 00:22:01 +0100 )edit

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.

Pi Chef gravatar imagePi Chef ( 2017-11-21 18:31:55 +0100 )edit

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.

Pi Chef gravatar imagePi Chef ( 2017-11-21 18:53:42 +0100 )edit

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 ✔ on the left side of the answer.

Jim K gravatar imageJim K ( 2017-11-21 20:17:29 +0100 )edit

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

Pi Chef gravatar imagePi Chef ( 2017-11-21 21:14:06 +0100 )edit

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

Jim K gravatar imageJim K ( 2017-11-23 19:23:52 +0100 )edit

@Jim K - Unfortunately, "mouseover" isn't a feature of the iPhone that I'm aware of. ;) 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". :(

Pi Chef gravatar imagePi Chef ( 2017-11-25 00:37:38 +0100 )edit

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

Jim K gravatar imageJim K ( 2017-11-25 19:19:03 +0100 )edit

Thanks. Now it’s officially “Answered”.

Pi Chef gravatar imagePi Chef ( 2017-11-25 20:57:58 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-11-18 23:56:57 +0100

Seen: 361 times

Last updated: Nov 25 '17