Skip to content

Instantly share code, notes, and snippets.

@AndiH
Created August 29, 2013 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndiH/6377814 to your computer and use it in GitHub Desktop.
Save AndiH/6377814 to your computer and use it in GitHub Desktop.
Count number of Chrome tabs (=processes, since every tab runs in its own process) and printout to file
#!/bin/bash
# Will print to amount of currently running chrome processes to a file
# Run every 5 minutes via cronjob a lá */5 * * * * ./Users/Andi/Desktop/countChrome.sh
# Or, better on OS X, use launchd
# Note: On Linux, there's a different pgrep version, use the first, commented NUMBEROFCHROMEPROCESSSES (untested)
#
# 29.8.2013 Andreas Herten http://www.andreasherten.de/
PATH=/usr/local/bin:/usr/bin:/bin
#NUMBEROFCHROMEPROCESSES=$(pgrep -i -c chromium | sed 's/^ *//g')
NUMBEROFCHROMEPROCESSES=$(pgrep -i chrome | wc -l | sed 's/^ *//g')
TODAY=$(date +"%Y-%m-%d %H:%M:%S")
OUTPUTFILE="chromeProcesses.csv"
ABSOLUTEDIR="/Users/Andi/Desktop"
echo "$TODAY"";""$NUMBEROFCHROMEPROCESSES">>$ABSOLUTEDIR/$OUTPUTFILE
@AndiH
Copy link
Author

AndiH commented Jan 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment