I would like to use crontab in Bash on a Raspberry Pi to open a mp4 video at certain times. I am very much a newby can anybody give me any advice or direct me where to dig further.

I had previously posted this message on the Rpi forum but was advised to post it here.

  1. Running under user account, use crontab -e to edit your user's crontab

    crontab -e

  2. Create a new entry in the crontab file:

| | | | | | 
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)
  1. The template above represents the fields you can enter into the crontab file. Think of each field as an entry followed by a space to separate fields.

For instance,

00 1 * * 1 * echo "hello!" >> ~/hello

would execute the command 'echo "hello!" >> ~/hello' every Monday at 1:00AM.

An asterisk represents an unused field, equivalent to N/A.

Make sure whatever command you're using has permission to modify the files/folders you want to modify.

  1. Save the crontab file after you're done editing and it will run at the next instance.
  • While this information is correct it won't help the user "open a mp4 video at certain times". – roaima Jan 26 '17 at 21:12
  • That would be entirely dependent on what command the user is using. Since they didn't specify, I gave them the tools to add that command in. – Patrick Jan 27 '17 at 17:17
  • No, the point is that no matter what command they add, it won't work from crontab without the user jumping through hoops. Take a look at my "possibly relevant" links on the OP's question itself. – roaima Jan 27 '17 at 17:43
  • The ease of use of the tool is entirely opinion-based. While there might be an easier way to do this, using at or some other method, the user specifically mentioned using a crontab, so I gave them the instructions to do so. I understand your point, but your initial comment that it "won't help" is subjective. – Patrick Jan 27 '17 at 22:43
  • I guess that my question was too broad. But before I got down into the details my first question was "Will crontab be functional with Bash". I understand that Bash is a subset of Unix but does it include the required features to be able to use the command on a Raspberry Pi computer. – Harold Jan 30 '17 at 11:36

You could use omxplayer for that, run crontab -e, (choose an editor if you haven't already), go to the bottom of the file and add:

32 15 * * * omxplayer -o hdmi /path/to/video.mp4

Where 32 = minute and 15 = hour. Note that you may need to export DISPLAY=:0 before.

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.