Schedule recurring screenshots

I need to take screenshots preferably every 15 seconds. I would prefer to name the file as the current date/time. I am assuming I cannot do this with cron as from what I know I can only narrow it down to a minute. Essentially I want to compile all of these images into a time-lapse video of server activity as shown by Activity Monitor and various other GUI tools. Anyone have any tips on how this could be accomplished?

Quad G5, Mac OS X (10.4.10), 6GB RAM 250GB HD

Posted on Jul 18, 2008 12:03 PM

Reply
4 replies

Jul 19, 2008 12:08 PM in response to Brent Hilgenkamp

You're right - you can't use cron for anything less than one minute intervals.

However, that's not to say you have to use cron at all - a simple shell script with a sleep 15 inside a loop would do it.

One consideration, though, is that screenshots aren't the best way to capture server activity. A lot of things can happen in a 15 second interval.

Therefore I recommend evaluating what it is you're trying to achieve, then seeing if there's a better way of doing it.

For example, if it really is screencasting/recording you're after, there are a number of utilities that will do this such as Snapz Pro or ScreenFlow - both have the ability to record screen activity and you can control frame rate, etc.

If it's just cpu activity you're trying to capture (e.g. which process is using all your CPU resource) then just run top which will show more detail than Activity Monitor, can be set to update on any interval and its output can be written to a file just like any shell command, e.g:

top -l 10 -s 15 > /path/to/log


This command will run top and capture 10 samples of data at 15 second intervals. The output will be written to /path/to/log, and each sample includes a timestamp at the top.

Jul 21, 2008 9:49 AM in response to Camelot

Thanks for the helpful information. I like what the screenshot utilities that you recommended can do, however a would prefer a free method, which led me to the screencapture command. I don't really know anything about scripting though. Do you think it would be possible to put this in a loop like you mentioned and name the file with the date/timestamp?

Also, since I've got ya here - do you know of any good online tutorials about scripting and the shell in general? I would like to learn more, but don't really know what to search for.

Jul 21, 2008 1:45 PM in response to Brent Hilgenkamp

Do you think it would be possible to put this in a loop like you mentioned and name the file with the date/timestamp?


Sure:

#/bin/sh
while \[ 1 \]; do
/usr/sbin/screencapture -T0 ~/Desktop/screen-`date +%F-%H-%M-%S`.png
sleep 15
done


This will run forever, until cancelled/killed. You can change the location of the screencapture (I have it set to the user's Desktop), as well as the filename.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Schedule recurring screenshots

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.