inicio mail me! sindicaci;ón

Archive for June, 2009

How to Run a Cygwin Command From Windows Scheduler (Scheduled Tasks)

After repeated problems setting up crond to run in cygwin (it just doesn’t like the user accounts, no matter how enthusiastically I argue that I’m me), I spent some time figuring out how to run a Cygwin command as a scheduled task from Windows scheduler. Here is what I figured out.

Based on this mail archive post, I created the following cygrun.bat file:

    @echo off
    rem set HOME=c:\
    if "%DEF_PATH%"=="" set DEF_PATH=%PATH%
    set PATH=c:\cygwin\bin;%DEF_PATH%
    set myargs=%*
    if "%myargs%" == "" goto noarg
    rem echo %myargs%
    bash --rcfile %HOME%/.bashrc -i -c "%myargs%" 
    c:
    rem pause
    sleep 1
    goto exit
    :noarg
 
    rxvt -e /usr/bin/bash --login -i
 
    :exit
    exit

Then I tested the script from the command line as follows, until I had the syntax just so:

c:
cd \cygwin
cygrun.bat cygwin_script arg1 arg2

Once I was able to run it happily, I added the scheduled task as follows:

    Run: C:\WINDOWS\system32\CMD.EXE /x /c start "Some title" /min
c:\cygwin\cygrun.bat cygwin_script arg1 arg2
    Start In: c:\cygwin     <-- must be a real disk drive and path
    Run as: domain\username

Unfortunately, I was never able to figure out how to redirect stdout and stderr. I tried plenty of variations on “>> /some/path/to/log.txt 2>&1″ with no joy. Instead, I just changed all the commands in the script and added that line on to each echo statement. Sad, but functional.

Teaching Cron to Run Every Ten Minutes

I got tired of hacking cron and typing in ridiculous things like 0,5,10,15,20,25,30,35,40,45,50,55 to tell my cron jobs to run every five minutes.

Knowing that if I was annoyed by it, someone else with more time had probably suffered too, I hit Google. The result was surprisingly easy…
Read the rest of this entry »

Extending the Windows Clipboard

For programmers and writers, being able to keep a history of copy/paste and access it with a hotkey is a serious boon. Here are some of the ways I use a clipboard tool daily (sometimes fifty times a day):

  • Take notes quickly–store a url, email address, or command for reference later
  • Reorganize a document–clip here, copy there, then paste it all together
  • Store commonly used commands and html strings for quick access
  • Passwords that I type more than ten times an hour
  • Storing things I use daily: IP addresses, dates, sql queries, urls

 

I’ve tried a few different tools, like Comfort Clipboard and XNeat Clipboard. But nothing beats Spartan for simple, direct, fast, and capable.

It allows you to store most any sort of formatted text, has 36 quick copy/paste slots, and multiple columns where you can drop text for different topics to store permanently and access them with a click.

If that wasn’t enough, it offers 10 different views, each with full hotkeys and columns. I’ve set mine up with CTRL+\ as a hotkey, so I have quick access to anything on the clipboard at the speed of typing.

It has a trial period, and is well worth the 20 bills for the full version.

For those with a little less robust needs, they also have a free version, 101clips, that is quite capable. Though I couldn’t live without the advanced capabilities of the full version.