Stories
Slash Boxes
Comments

SoylentNews is people

Journal by fliptop

As I've stated several times, cheap IP cameras are a little flaky. So even if you calculate the appropriate number of pictures to take in a 24-hour period, midnight will inevitably arrive and the script will still have a handful or two of pictures left to take.

So first we need to kill off the previous day's job. Here's the way to do that from cron:

00 00 * * * /bin/ps -o pid,args -U fliptop | /bin/grep grab_pic_tv-ip551wi.pl | /bin/grep -v grep | /usr/bin/xargs /bin/kill -15

Substitute the username your scripts run under for the -U switch and the name of your perl script in the 1st grep. Basically, this command takes all process that run under a particular user, greps out just the one process your script runs as, throws out any instances of the grep statement itself that may make their way into the results, then kills it w/ signal 15.

Next, at one minute after midnight, we start the next instance of the script for the new day:

01 00 * * * /bin/nice -n 19 /usr/bin/perl /home/fliptop/tv-ip551wi/grab_pic_tv-ip551wi.pl

Again, substitute the appropriate script location and name. I usually run these things nicely so they don't interfere too badly w/ other processes that run from time to time.

All that's left is to create the movie from the previous day's images:

03 02 * * * /bin/nice -n 19 /usr/bin/perl /home/fliptop/tv-ip551wi/ffmpeg.pl

As before, substitute the proper location and script name. You can run this at any time after midnight.

As you can imagine, watching surveillance video can be pretty boring since most of the time there's nothing noteworthy happening. However, once in a while you can see some damn interesting weather. One day last May I was reviewing some footage and thought to myself, "that would probably look pretty cool if it was edited a little w/ some Vivaldi."

Coming next, cleaning up your images.

 

Reply to: Better way to kill procs

    (Score: 2) by evilviper on Thursday April 10 2014, @12:06PM

    by evilviper (1760) on Thursday April 10 2014, @12:06PM (#29391) Homepage

    That multi-pipe kill command seems like an awfully long way to go... The following should do the same job:

    * pkill -u fliptop -f grab_pic_tv-ip551wi.pl

Post Comment

Edit Comment You are not logged in. You can log in now using the convenient form below, or Create an Account, or post as Anonymous Coward.

Public Terminal

Anonymous Coward [ Create an Account ]

Use the Preview Button! Check those URLs!


Score: 0 (Logged-in users start at Score: 1). Create an Account!

Allowed HTML
<b|i|p|br|a|ol|ul|li|dl|dt|dd|em|strong|tt|blockquote|div|ecode|quote|sup|sub|abbr|sarc|sarcasm|user|spoiler|del>

URLs
<URL:http://example.com/> will auto-link a URL

Important Stuff

  • Please try to keep posts on topic.
  • Try to reply to other people's comments instead of starting new threads.
  • Read other people's messages before posting your own to avoid simply duplicating what has already been said.
  • Use a clear subject that describes what your message is about.
  • Offtopic, Inflammatory, Inappropriate, Illegal, or Offensive comments might be moderated. (You can read everything, even moderated posts, by adjusting your threshold on the User Preferences Page)
  • If you want replies to your comments sent to you, consider logging in or creating an account.

If you are having a problem with accounts or comment posting, please yell for help.