Setting a CRON on MAMP

I need to set a CRON job on MAMP on a local machine.

A few searches suggest I need to open terminal type crontab -e Then press i on your keyboard to go to vim’s insert mode. Then type in your cron command like…

*/5 * * * * /usr/bin/curl --silent --compressed http://localhost:8888/myscript.php

Before I do, natural fears of under the hood terminal tinkering make me nervous. Are there any wise words anyone could offer before I cause OSX to fall down like a pack of cards?

David


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Did you see this MAMP thread?
http://forum.mamp.info/viewtopic.php?f=2&t=15185

It’s always been my (perhaps incorrect) understanding that cron jobs
will run regardless if the Apache or MySQL servers (or in your case,
MAMP) are running or not. Someone in the above thread also makes the
same claim. I have poked around a little with cron jobs in the past but
I remember using a free 3rd Party app, not Terminal, which made me feel
more comfortable than using Terminal. Sorry I can’t be of more help.

Todd
http://xiiro.com


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes I remember called CronniX? Hunted around in my apps and still got it.

Still runs but is old and not sure whether to trust ~ 2007

David

On 14 Aug 2012, at 15:34, Todd wrote:

remember using a free 3rd Party app, not Terminal,


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

David Owen wrote:

Yes I remember called CronniX? Hunted around in my apps and still got it.

Still runs but is old and not sure whether to trust ~ 2007
Yeah, that’s the one I used. From what I’ve read on MacUpdate it has
some (minor?) issues with recent OS.

There’s also Lingon which seems to support the current OS.
http://www.peterborgapps.com/lingon/

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

At 12:51 +0100 14/8/12, David Owen wrote:

I need to set a CRON job on MAMP on a local machine.

A few searches suggest I need to open terminal type crontab -e Then
press i on your keyboard to go to vim’s insert mode. Then type in
your cron command like…

*/5 * * * * /usr/bin/curl --silent --compressed
http://localhost:8888/myscript.php

Before I do, natural fears of under the hood terminal tinkering make
me nervous. Are there any wise words anyone could offer before I
cause OSX to fall down like a pack of cards?

cron is a standard Unix daemon that is independent of MAMP. If you’re
running pre-Lion I think it should be running. It isn’t on my wife’s
Lion mbp but it is on all my SL Macs.

As long as the command you get cron to run will run safely from the
command line, and any environment variables it needs are also set in
the cron environment, it should work.

Unless you’re running as root it’s very difficult to get Unix to fall
over. Students the world over have been trying for years.

David


David Ledger - Freelance Unix Sysadmin in the UK.
email@hidden
www.ivdcs.co.uk


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Lingon uses Lauchd. Which offers an easy way of running an app (like an applescript to run a bookmark to open a browser window to run the php script).

The neater way would be to run the script direct. Do you know what the correct root path run a php script in MAMP http://localhost:8888/myscript.php

The script being in the Applications/MAMP/htdoc/myscript.php

And the correct command for lauchd to run it?

David

On 14 Aug 2012, at 16:04, Todd wrote:

There’s also Lingon which seems to support the current OS. http://www.peterborgapps.com/lingon/


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you want a cron job to run on your Mac, I would recommend that you have that job call to a service that you know is running all the time. MAMP is designed to “sandbox” the traditional AMP (Apache, MySQL, PHP/Perl) stack away from the foundations of the OS. It runs in what’s called “userspace”, as an application that the currently logged-in user can launch and run. And when it isn’t running, neither are any of the services (AMP) that it launches.

Your Mac ships with the command-line php interpreter installed, you can find out what version by opening a new Terminal window and typing which php. You can also set the mod_php Apache module to run by default by modifying the httpd.conf file, usually found at /etc/apache2/httpd.conf. There are two lines related to this, they will each have a # at the beginning of the line, remove that, and you will have php running in your regular Web Sharing at all times. If you place the file(s) you wish to interact with in the /Library/WebServer/Documents folder, you will be able to hit them from cron at any time your Mac is powered on. No user will need to be logged in, your Mac will be behaving like the grown-up Unix server that it is.

Long way to say this: if you want to use cron to launch a service or send a command to a running service, you will have the very best results by making sure that the service you want to hit is always running at all times that your Mac (the server) is powered on.

If you want to set up a periodical “Launch this application and do this thing” command that involves userspace applications, then I would recommend you use Automator (which will write AppleScript for you) as that is its defined job in life.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options