|
|
Cron Jobs - Cron Jobs In Cpanel - Cron Jobs : Cron Jobs using PHP | ||
Discussion by OpaQue with 38 Replies.
Last Update: March 27, 2012, 10:06 am ( View Rated (1) ) (View Latest) | Page 1 of 2 pages. | ||
![]() |
|
|
Ok. Many people are yelling that they cannot configure the crons properly.
Here is a short tutorial which will help you set them. I have tried my best to explain the concept but there can be more advanced configurations.
Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file called maintanence.php every one hour. This is what you do :-
[
The CRON Command is in the Following Format
CODE
[ Minute - Hour - Day - Month - Weekday ] - CommandThe COMMAND, can be broken down in
CODE
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]So the COMPLETE CRON command can be written as
CODE
[ Minute - Hour - Day - Month - Weekday ] [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]The timing is spedified using * symbols
CODE
* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekday
If you did not understand anything till now.. Good, this means you are a noob.. Read ahead
Since this is a UNIX command, You will have to Mention the PATH of PHP. At Astahost,
CODE
PATH TO PHP : /usr/local/bin/php( it also same at trap17, if users over there want to use it )
These are the Possible Command line Arguments you can use. This will effect the output. In our case, we will use the -q ( Quiet mode ) argument.
CODE
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
The Path of the PHP file Must be Complete absolute path.
If you have an Account at TRAP, And your USERNAME is "tom", Your path will be
"/home/tom/public_html/"
I assume you are familier with the PUBLIC_HTML directory. That is the Root folder where you store your html files.
So lets say that Tom wants to execute my script "maintenance.php" every hour. And it is stored in "public_html/cron/maintenance.php";
So the Complete CRON command would be,
CODE
0 * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.phpIf tom wants to execute it every minute, he would use.
CODE
* * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.phpIf tom wants to execute it every Month, he would use.
CODE
0 0 0 * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.phpThere are more Complex forms of Assigning the TIMINGS for these scripts. You can go to CPANEL => Cron Jobs => Standard and set exact time when the script will be executed.
Also, this method used php, you can also use Curl .
-OpaQue
QUOTE (OpaQue)
if tom wants to execute it every minute, he would use.CODE
0 0 * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.phpbut shouldn't you use * * * * * for the time if you wanted it to run every minute?
All other Cron help was for experts. I could not figure the correct command and can now see what is ment by argument. Will be trying this info on my site. You see I need it to update information every 2 weeks.
It does an action every "X
When you have a file : update.php
And you want to load it every day at midnight. You don't have to go on this page yourself. The cron does it and you don't have to do anything, it is really usefull
Exemple :
CODE
update.phpmysql_query("UPDATE members SET point = point + '1'");
If the cron is activated on the page update.php, everyday your members will get 1 more point
QUOTE (maddog39)
Ok, so I still dont get the point of cron jobs. Are they just server settings that allow you to execute a command within a set ammount of time?Exactly !
This program has led me into making my own PHP cron >_>
I have a MySQL table named "other" with fields "name'" and "content".
CODE
if(mysql_result(mysql_query('content','other','name = \'cron\' AND content <= UNIX_TIMESTAMP()-60*60*24'), 0)){
// cron stuff goes here
// Update the cron time
mysql_query('UPDATE other SET content = UNIX_TIMESTAMP WHERE name = \'cron\'');
}
This is sort of the way my script is, it's a good script 'cause it doesn't take much time out of the user. It's in the head file so it'll get run when needed. The cron stuff gets runned every day.
my full nightly command (midnight EST):
0 19 * * * /usr/local/bin/php -q /home/gamefaqs/public_html/cron_omgwtflolbbq/daily_purge.php
did i forget something? am i supposed to put a "GET" in somewhere?
please help! this is really important for my site!
thanx in advance
7 different people tried it and none of them worked. 7 people.
and none worked.
I'm using the LUE2 source and I need cron jobs to run important parts of it.
I need it for something called karma and something called gems, which is the curreny needed to buy certain items I put in the shop. It's pretty interesting; check it out some time.
Anyway, I also have a game on there to, which also needs crons to give people experciance points and gold to buy stuff from the game's shop.
But yea, if you could help me with it OpaQue, I'd really appreciate it. And I'll let you come to my site anytime you'd like. >_>
I have a php file that just needs to be processed in order for it to work. So all i would do is type in the address of the php file, and it would start processing log files. I want to do this remotely from my webhost site. So I was told once that i could use
CODE
#wget http://www.mysite.com/update.php
and that would run that page at the time I wanted. But it didn't do anything.
Then i saw someone use:
CODE
get http://www.mysite.com/update.php
tried it, nothing happened.
so is there a way to just have the cron job access a remote file by the webaddress?
The way I have it set up is this.
3 Tasks.
Task 1) call on a remote url that is on my home pc to do a log file parse. This is done simply by accessing the php file through any browser, thats it.
Task 2) call on a remote url to do a database backup of the database on that server. Now thats the logs are parsed, it updated the database with all the parsed info.
Task 3) call on a local file to do a database restore to the mirrored database on the webserver, i.e. make the webserver db match my homepc db.
This all works fine if i do it manually. but what command allows the cron job to do it?
CODE
/usr/local/bin/GET -C root:pass http://my.ip.add.ress/folder/logs.php?pass=update
this does the trick. loads the remote file.
QUOTE (DssTrainer)
ok I found it.CODE
/usr/local/bin/GET -C root:pass http://my.ip.add.ress/folder/logs.php?pass=update
this does the trick. loads the remote file.
ok nevermind that doesnt work.
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 1: ?php: No
such file or directory
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 2:
/aquota.user: Permission denied
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 3:
mail_digest.php: command not found
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 4:
: command not found
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 5: begin:
command not found
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 6: syntax
error near unexpected token `('
/home/mysitename/public_html/directory/protecteddirectory/mail_digests.php: line 6: `
copyright : © 2000 The phpBB Group'
Any ideas why?
i'm noob but follow this tutorial, i can configure cron job successfully
this can be old topic but i just wanna express my succeed!
thks opaque
and you can Manage the script with corn to run
for example counter
Dear Seņor Maniac
corn is working for all trap17 members , but you must active corn first
How do i set the cronjob if i want to run the task for every 5 minutes in advance mode
coby
Cron Jobs - Cron Jobs In Cpanel
* * * * * /usr/bin/php -q /var/www/virtual/tenzin.Com/htdocs/script.Php
<?php
//("script.Php has chmod 755 script.Php")
$line = 'hello world';
File_put_contents('cron.Txt',$page,FILE_APPEND);
?>
-question by tenzin
/usr/bin/crontab permissions are wrong. Please set to 4755
Is it an error ? and how can I resolve this problem? where to put this dir and so on..
Please help
Thanks In Advance
Cron Jobs - Cron Jobs In Cpanel
Hi. Can someone please tell be how to find the path to php. I'm uusing cpanel
In the past, I found a post that had a command to put in a page, to display the path. Does anybody know. It was really helpfull, just cant find it now. Thanks pat
Anywho, what exactly is the '/usr/local/bin/php' used for and is it needed? also, I'm getting errors in my email that state the script cant find my required files. Anyone know why this would be?
Thanx
-reply by ryan
Cron Jobs - Cron Jobs In Cpanel
Tenzin, is this a test? the first thing I noticed is .Php and .Txt for an extension... Thats kinda funky. The second is your chmod. 755 is for folders, try 644 for your files.
Also, food for thought, making a call to file_put_contents will create the desired file if it doesn't exist. So, this file should have the correct chmod at creation. You can use this to verify the correct chmod for your files.
Hope that halps
-reply by riin
Can anyone tell me how to disable a cronjob?
Thanks...
- Log in to cPanel
- Scroll to the bottom of the page, and click Cron jobs in the Advanced section
- Click on Standard
- Click Delete on the cron job you want to get rid of
Cron Jobs - Cron Jobs In Cpanel
I've activated cron job in cpanel, but I get error. What's wrong ?
"/bin/sh: usr/local/bin/php: No such file or directory"
Pls help .. Tq
-reply by han-han
Cron Jobs - Cron Jobs In Cpanel
Good morning,
I have a host to make cronjob. However, the script called is a bigger level memory is the 32M given to my script is not enough.
I therefore creates a file with the directive htaccess php_value memory_limit 200M, when I call myself this script with a browser my script ends properly because I now has 200M memory.
But now when I set my cron job with this script is well I return errors memory allocation, it seems that the htaccess file is ignored. I tested raise_memory_limit ( "200M"), ini_set ( "memory_limit", "200M"), but nothing done.
The call from my script "php / home / sqdqs / monscript.Php," there is no t'il php parameters to be included in the order (genus php-q)?
Have you any idea of solution?
Thank you
-reply by Smalldevil
Similar Topics:
Cron Jobs Not Working In Cpanel
How To Configure Cron Jobs?
Cron Jobs
**** Read Before You Post! **** THIS MAY AFFECT YOUR HOSTING CREDITS (52)
|
(8) Cinema 4d | Abstracts
|
Loading...
HOME 





Easy CPanel Backup Automation using Cron job and PHP script
cPanel Hosting, MySQL, Fantastico, AWStats, Cron Jobs, All Made Easy Tutorial
How to set up the WHMCS cron job using cPanel - WHMCS Tutorials
How To Setup Cron Jobs In cPanel | Website Hosting Tutorial
How to set up a cron job
Setup a cron job in cPanel | cPanel Cron Job
How to set up a Cron Job
How To Set Up Cron Jobs On Your Hosting Account Control Panel Run Script
Tereas Programadas,cron job desde el Cpanel
Cron Job Tutorial: Automate the Email Sending for Newsletter

