You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial).
Because of this, it is possible that our website may not appear
correctly in your browser. We apologise for the inconvenience, and
recommend you upgrade your browser to one which is compatible with CSS.
For more information, please visit our Browser Upgrade page.
Ever needed to run a particular Unix command, PHP or Perl script regularly? You obviously can't be bothered to run it manually every so often (especially if it has to be run daily!). So what are you going to do? Use cron - your saviour!
Cron is a Unix scheduling utility. The syntax is a bit cryptic, but it can be figured out. You'll need to either have telnet (shell) access to your server, or some other way to interface with it (like 34SP's cron front-end). You'll also have to have a host which allows you to run cron jobs.
For example, I have the following two entries in my crontab (cron table):
42 2 * * 0 /usr/bin/zip -q access-log.`/bin/date +\%m\%d`.zip
access-log
59 23 * * * /home/server_name/other_path/batch/snapshot.sh
I've changed the names to protect the innocent. Reading from left to right, the first few symbols (numbers or *) refer to when a job will run. For example, the second entry in my crontab runs at 23:59 (that's 11:59 pm). Since the next three items are *, it runs on every day on every month, no matter which day of the week it is. The first job zips up the access logs for my web site, at 2:42 AM, but only on Sunday. It doesn't matter which day of the month it occurs on, it just happens every Sunday.
After that cryptic beginning, the rest of the line is just the command to run. So suppose you wanted something to run on the 15th at noon, but only if it was a Saturday. Then your cron entry would look something like:
0 12 15 * 6 your_job_here
When cron looks for jobs to run, this job will only run at noon (12:00) on the 15th (15) of any month (*) when that day is a Saturday (6). In other words, not very often.
The five fields, in order, are minute (valid values: 0 - 59), hour (valid values: 0 - 23), day of month (valid values: 1 - 31), month (valid values: 1 - 12, or use names), and day (valid values: 0-7, Sunday is 0 or 7, or use names). Any of these fields can be a *, which means match all values. You can also use a comma-seperated list of values, like this: 1,2,3.
I've been using the terms "cron" and "crontab" as if they were the same, however, they're not. Cron is the Unix program which wakes up every minute and looks for jobs to run. Crontab is the database or listing of jobs to consider. I don't own my host, so I don't have access to run cron. But I can use the crontab command (-r to remove, -e to edit, or -l to list) to set up cron jobs which will be run on a schedule that I set up. The listing of jobs above was generated with crontab -l.
Because cron runs as root, you should fully qualify your path names to any scripts that will be run. For example, you shouldn't use:
/batch/snapshot.sh
You should use the full path:
/home/path/batch/snapshot.sh
So, to sum up, here is the crontab syntax:
[minute] [hour] [day of month] [month] [day of week] [command to run]
If you wish to receive errors by email, add the following line to the top of your crontab:
MAILTO="your_email_address@domain.com"
© 4WebHelp and Dave
Prepared for publication by Daniel.
My question is
In unix cron, i want to run a script in such a way that it should find the files ( including the maximum and minimum size) and after finding it, it should compress on daily basis.
Please help me out.
Thanks in advance
a am wondering if i can execute php script via telnet in cron?
in this way (symbolic:):
*/1 * * * * sudo IP -f php/path script/path
i'm monitoring remote machines in one specific env.
thx in advance
THANX
affordable and reliable.
It's possible to set a test account there as well.
i am using PHP5 ,Apache,..if anyone know the solution tell me
i want run that script daily basis at particular time
How would i be able to do that?
I have one perl script on unix environment.
I want it to run as cron job every 6 hour of the day. It would be of great help if someone can help me from the begining phase.
Thanks!
How do i get cron to run for:
1. every 15 mins;
2. every 12 hours;
3. Every 60 mins.
Much appreciated
Find great many questions unanswered here. I've one simple requirement. I need to parse and XML file uploaded by users every minute.I've written parser in PHP. I need to run parser.php and the delete the files or move to another folder.
Any suggessions welcome.
Cron has afew folders cron.daily, cron.weekly and cron.monthly. Simply do a locate command from a shell eg. "locate cron.daily" and place your script into that folder It will run daily, weekly or monthly, depending on what folder you placed it in.
Its easy for backing up automatically. For example if you open notepad and type "\cp -r /home/ /backups/" and save it as backup.cron and place it into cron.daily dir. Your server will make a backup daily (at 12.00 am [depending on the OS]) into /backups/.
Now running a PHP script to run every 15 min.. I'm not telling, learn what i've just wrote first. What you want to do is more advanced, and sometimes not possable.
I have a host with cron, and I wonder where I am supposed to put the command 'min hr day ** command' to a file, and how to name the file so cron will pick it up etc.
Basically, from the tutorial I know how to write a cron command, but I dont know how to actually set up a cron job.
thanks.
papayiya
If you want to send specific content to different people, then create your own script that send the emails and call it with cronjobs every 72 hours (this should be free).
can you exaplain to me cron jobs with example, i want to send email after 72 hours
and only advance features are not free !
If not you can use the services of http://www.webcron.org/ (in French but easily translated I think).
Can u please help me with this.
How can i run " www.abc.com/mail.php "
daily.
plz help me in this regard
thanx
Bye
Good luck,
George
i found an useful cron job manager written in php, it have good syntax (like unix-style).don't required any external things, only php and apache!
http://www.bitfolge.de/pseudocron-en.html
cron_bounce.php -- every 12 hrs
cron_responder.php -- every 60 minutes
thnx
When cron looks for jobs to run, this job will only run at noon (12:00) on the 15th (15) of any month (*) when that day is a Saturday (6). In other words, not very often.
I don't think this will work this way in cron. From what I have read, it will run if either condition is true, either it is the 15th of the month or it is a Sat.
The */10**** part is not part of the command - it tells cron when to run the script. I don't know if you're using a graphical interface to cron (a Perl/PHP script, or cPanel's editor), but if you are the command is separate from the scheduling. Also there should be spaces between the stars.
I have just started to use cron and im a little confused.
I have tried several different commands to get this php script to run but no dice.
When I run the command */10**** /home/username/public_html/services/scheduler/tools/send_reminders.php
I recieve an output email that says
Quote:
In the subject line of the email it actually has the url to the script. If I click on the url I get this in the browser.
Quote:
Know what I have done wrong here?
Please post in our forums for help - the comments system is not designed for support.
Add a new comment