I saw cron job in my cpanel There I can choose the time for the job. and just remains the command input field. It that going to be filled with a sql statement? please give me a sample command line assuming database articles with username: m2babaey and password: pass123 I really need it :roll: I wish I could insert the following code in the command field: <?php $result=mysql_query("select* from table where expiredate-7<now()"); while($row=mysql_fetch_array($result)){ mail( $row['email'] , "Reminder" , "Please act for rebilling ASAP" , "admin@billing.com"); } ?> PHP: (I'm not sure about expiredate-7<now() ) Is it possible? and one other thing will I need swift mailer If I use cron job to mail? Thanks
You can use CRON to do anything you like. But, understand it runs operating system commands. It's an operating system tool. So, if you want it to run SQL, you need to issue command line format queries. If you wish it to run php, again, you need to create a php page and issue a command line call to get the php executable to execute them. Finally, yes you can use cron to send emails, or to call a php page that sends them. By far the easiest way to do it is to create a php page that does everything you need, and then write a cron job that simply calls that page every 5 mins or once a day or whatever you need.
Thanks ecentricNick ! I will create a php file with the code above and save it in my root directory ( or should I save it in public html?) Then How can I call that php file to be executed? ( what should be the command line?)
Where you put it depends a little on how you call it (and whether it's on the same server as the cron job!). You can either call it through wget.... wget -O mysavefile.ping "http://pingoat.com/index.php?url=......." or through php directly... php -f /path/filename.php See php help.... [nottellingyou@eCmedia-001-001- playpit]# php -? Usage: php [options] [-f] <file> [--] [args...] php [options] -r <code> [--] [args...] php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...] php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...] php [options] -- [args...] -a Run interactively -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>. -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -r <code> Run PHP <code> without using script tags <?..?> -B <begin_code> Run PHP <begin_code> before processing input lines -R <code> Run PHP <code> for every input line -F <file> Parse and execute <file> for every input line -E <end_code> Run PHP <end_code> after processing all input lines -H Hide any passed arguments from external tools. -s Display colour syntax highlighted source. -v Version number -w Display source with stripped comments and whitespace. -z <file> Load Zend extension <file>. args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin
A CRON job/event is just to run a file at a certain time and date. It could be a one time thing or a reoccuring run of the file. The file is the portion that has the code in it.
I have one cron jobs in my cpanel and details like: in advanced(unix style) 0 0 * * * php /home/siteuser/www/aaaaa.php aaa.php <?php mysql_query("UPDATE sites SET hit = 0"); echo "Hits reseted successfully for directory: www.wezp.com"; ?> PHP: I reset hits every 24 hours with this codes.
why dont you use a free script that runs automatically on scheduling. see: www.best-php-scripts.com under mysql backups