Using CronniX to schedule WeatherCat to restart

From WeatherCat Wiki (Mahler)
Jump to: navigation, search

There are a number of reasons for wanting to automatically stop and start WeatherCat. It is recommended that WeatherCat not be run for periods of greater than a week. Another situation when restarting WeatherCat is useful is if you are allowing your computer to go to sleep on a schedule. Because not all weather station interfaces handle the sleep process gracefully, it is recommended that you quit WeatherCat before your computer goes to sleep and restart it after the computer awakens.

One way to do this is using Automator, but this can be inconvenience because it displays in iCal from time to time. Another way to do this is to take advantage of the built-in UNIX facility cron. This is a very tedious and unpleasant task for someone not used to UNIX, but now is easy to do thanks to the free utility CronniX.

There is one catch to using CronniX, cron (and therefore CronniX) can only run UNIX or OS-X applications. We don't have an application to start or stop WeatherCat. However, AppleScript provides a one-line solution to this problem.

Find your AppleScript Editor (which has different names depending on the version of OS-X you are running.) Open it and give yourself an untitled window if one doesn't immediately appear. Now enter into this window this single line verbatim:

tell application "WeatherCat" to activate

Now save this AppleScript as an Application. Do do this, select Application as the type of file from the pop-up menu at the bottom of the Save-As dialog. Save this file in some convenient spot on your computer that isn't likely to be disturbed. You could store it in your Applications folder of your home folder for example. Name the file something reasonable like Launch WeatherCat.

This AppleScript allows you to launch WeatherCat. You'll need a second script to quit WeatherCat. Again get yourself an untitled window in the AppleScript Editor and this time enter the following text verbatim.

tell application "WeatherCat" to quit

Save this as a second file. Again used good judgement as to where to save the file and name it reasonably like Quit WeatherCat.

Before proceeding any further, test that these applications do what they claim to do. Launch (double-click) on each one to make sure they cause WeatherCat to either launch or quit. If they work correctly, then you are ready to move on to scheduling them to launch with CronniX.

If you haven't already installed CronniX, download and installed the current version from CronniX project website. It is open-source so it is free to use.

Once installed, launch CronniX and you'll get a display of all the cron jobs running for your user account (if any.) Click on the new job button (which you will recognize from the illustration below:)

Cronnix add job.jpg

Now you must do several things to schedule a job that will run everyday. First, you must select the AppleScript to run. You'll need to check the Prepend "/usr/bin/open" for the AppleScript to run. Now click on the Browse button and navigate to the AppleScript file that you saved. In the example above, the AppleScript is different: Quit You'll see that your Application now has a suffix of .app .

Once you have selected the ApplesScript to run, you need to set the schedule. CronniX doesn't always open to the Simple Schedule. So click on Simple if you don't see what is in the illustration above. If you running the script every day, it will look like the example above. In this case, the script is set to run at 5:55am every day. The minutes are set first, then the hour (24 hour time), and so on. It is most unlikely that you will need to have something run on the day of the month never mind only some months of the year. However, if you want to restart WeatherCat on some day of the week, use the Day of the Week option to select that day of the week.

You need to schedule one job for quitting WeatherCat and a second job for starting WeatherCat once again. When you have created both jobs, don't forget to save the changes.

Given that you'll probably want all this to happen when you aren't at your computer, do yourself a favor and first schedule a test when you are in front of your Mac to make sure all is working well. Then change the scheduling to the actually time you wish these events to occur unattended.

Keep in mind that WeatherCat can take some time to quit. Make sure to give WeatherCat enough time. This could be lengthy if you are running AppleScripts and/or other accessory programs.

Obviously this technique can be used to schedule any sort of activity on your Mac.

Personal tools