Jump to content

Welcome, Guest!


Crontab with Raspivid/ffmpeg

Recommended Posts

Good morning all,

I seem to be having some issues with crontab lately and since I don't know much (or really anything) about it I was hoping you all could give me some pointers and help me get this pi running correctly!
OS: Raspbian (9 September release)
(pup.sh is my shell script that I have saved as root to run my raspivid command and is saved in /home/pi/pup.sh)
I created the pup.sh and accessed crontab as root with crontab -e after putting in sudo bash.

I have set up the raspberry pi camera and am running it with raspivid off a tutorial that I followed (can't link it here since I can't access the site at work). The raspivid is working great and is streaming the video to my ustream account just like it is supposed to. I have set up the raspivid as a way to monitor our new puppy while at work. I don't want to leave the camera running all the time so I was trying to get it working with crontab so that it will start and stop when I want it to. I've decided to just reboot when I want the raspivid to stop because a reboot never hurts and I have had issues using "killall". Here's the code that I'm using in root crontab:

00 0,11,17 * * * /sbin/shutdown -r now
00 7,12 * * 1-5 /usr/bin/screen -d -m /home/pi/pup.sh

Now I have ran the "screen -d -m /home/pi/pup.sh" command by itself and it worked. I was trying to update the crontab at lunch today and changing it to a few minutes ahead and then monitoring via "top". Sure enough at the specified minute raspivid would show up in the list of processes and then shortly disappeared from the list. Could the time in crontab and the time specified in the pup.sh (raspivid -t XXX) be throwing each other off? Here is what I found in "cat /var/log/syslog"

Oct 15 11:25:01 raspberrypi /USR/SBIN/CRON[2236]: (root) CMD (/usr/bin/screen -d -m /home/pi/pup.sh)
Oct 15 11:25:40 raspberrypi crontab[2252]: (root) BEGIN EDIT (root)
Oct 15 11:26:01 raspberrypi crontab[2252]: (root) REPLACE (root)
Oct 15 11:26:01 raspberrypi crontab[2252]: (root) END EDIT (root)
Oct 15 11:26:01 raspberrypi /usr/sbin/cron[2079]: (root) RELOAD (crontabs/root)
Oct 15 11:27:01 raspberrypi /USR/SBIN/CRON[2258]: (root) CMD (/usr/bin/screen -d -m /home/pi/pup.sh)
Oct 15 11:28:27 raspberrypi crontab[2271]: (root) BEGIN EDIT (root)
Oct 15 11:28:39 raspberrypi crontab[2271]: (root) REPLACE (root)
Oct 15 11:28:39 raspberrypi crontab[2271]: (root) END EDIT (root)
Oct 15 11:29:01 raspberrypi /usr/sbin/cron[2079]: (root) RELOAD (crontabs/root)
Oct 15 11:29:01 raspberrypi /USR/SBIN/CRON[2277]: (root) CMD (/usr/bin/screen -d -m /home/pi/pup.sh)

I hope you can help me figure this out, I've been working it for several weeks (and through several forums!) and am just getting more frustrated. I appreciate any help, advice, and information in advance!



Share this post

Link to post
Share on other sites

In your command


raspivid -t XXX


What value is XXX? Is it large enough? I think XXX is in millisecond, so XXX=1000 would mean 1 second

That might explain why raspivid shows up in top and disappears soon after.



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


About Us

Bringing you the latest Raspberry Pi news, tutorials and user forum.

The Fruity Computer

  • Create New...