简体   繁体   中英

Working Directory for a Cron Job

I am testing an application in MAMP and would like to add a cron job, or as I am on a mac the job through is run through launchctl . My cron is a php file that runs a database query. Naturally the php file and mysql db are in separate directories. Where should I change my working directory to such that the cron will query the database? FYI, I have a standard installation /Applications/MAMP/...

Many thanks.

My mistake above was that I was trying to point to the database's directory, when the php file had already handled that for me. Running the program was as simple as running the following code:

php -q /path/to/my/doc.php

I found it was easiest to manage launchtl through a $5-$10 program called lingon . Highly recommended if you are considering managing multiple crons at a time. Otherwise, if you want to stick to the command line, this is a good tutorial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM