Sunday, January 4, 2009

Scheduling a Task on Windows Per Minutes

Such an easy on job on Linux, turned out not so on Windows XP Pro and all I wanted to do is to export a process's info to a file every 5 minutes.

The Task Scheduler of Windows doesn't show you the option to run a periodical task per minutes.


After a quick search, I found out that it can be done in the command line interface (CLI).
C:\PsTools>schtasks /Create /SC MINUTE /MO 5 /TN javawatch /TR C:\PsTools\batch.bat
The task will be created under current logged-on user name ("ADRENALIN\Administr
ator").
Please enter the run as password for ADRENALIN\Administrator: ******
SUCCESS: The scheduled task "javawatch" has successfully been created.

After this, the task will show in your graphical task scheduler program:


You can see that the 5-minute interval is hard-coded into it!


As you can see in the CLI code, I'm pointing the task at a batch file. Contents of "batch.bat":
time /t >> java_watch.log
C:\PsTools\pslist.exe -m -e java >> java_watch.log

pslist is not a standard Windows tool but can be obtained for free here. It comes along with many other useful tools so make sure you check them out.

Anyway, I used pslist to extract memory info from a process called "java" -- you could omit the -e flag and just provide the process ID (PID).

Thursday, January 1, 2009

Finding Words from a Set of Letters

grep "^[asdfzxcv]\{4,\}$" /usr/share/dict/words

Will search the file words, which contains a heap of English words, for words that consist of any of the enclosed letters, of a length of 4. You can manipulate the letters or length as pleased.

Use this for what, you may wonder. Well, wonder no more! If you're trying to find what words can be formed from the right-side of the keyboard, for any number of characters, well, here's your solution! Tada!

ALL HAIL THE POWER OF REGEX!