Jump to content

CRON JOB


raji20

Recommended Posts

Firstly you'll need a script that checks the POP server for new mail and sends it to the new email address:
Documentation: [url=http://www.php.net/imap]http://www.php.net/imap[/url]

This is just some example code for imap:
[code]
<?php

// This gets the first email in the mailbox
$mailbox = imap_open("{localhost/pop3:110}INBOX", "#username#","#password#");
$check = imap_check($mailbox);
$new_messages = ($check->Recent ? true : false);

$index=1;

$header = imap_header($mailbox, $index);
print("<PRE>");
print("Header Date : " . $header->Date . "<BR>");
print("Header To : " . $header->to) . "<BR>";
print("Header From : " . $header->From . "<BR>");
print("Header cc : " . $header->cc . "<BR>");
print("Header ReplyTo : " . $header->ReplyTo . "<BR>");
print("Header Subject : " . $header->Subject . "<BR></PRE>");

print("<PRE>");
print(imap_body($mailbox,$index));
print("</PRE><HR>");

imap_close($mailbox);

?>
[/code]

Then add this line to your cronjob:
0  12  *  10  1-7 /user/bin/php -f /location/of/scripts/to/execute.php

[url=http://www.adminschoice.com/docs/crontab.htm]http://www.adminschoice.com/docs/crontab.htm[/url]
Link to comment
https://forums.phpfreaks.com/topic/25025-cron-job/#findComment-114056
Share on other sites

First Thanks a lot for your assistance,


when i try to excute this comand from the linux server,

0    12    *    10    1-7  /usr/local/lib/php -f /www/htdocs/phpdocs/test/cron.php

it pops up the error saying

-bash: 0: command not found

Is it correct what i have done or please guide me how to add this line to CRONJOB, Im very new to this topic.




Link to comment
https://forums.phpfreaks.com/topic/25025-cron-job/#findComment-114071
Share on other sites

thanks again for your assistance, when i tried this following command from the linux server

[root@place etc]# crontab 0    12    *    10    1-7  /usr/local/lib/php -f /www/htdocs/phpdocs/test/cron.php

it shows me error saying

crontab: invalid option -- f
crontab: usage error: unrecognized option

Can you please tell me about what i have did is correct or not, if it is wrong what i need to do, if it is correct how to correct this error.
Link to comment
https://forums.phpfreaks.com/topic/25025-cron-job/#findComment-114094
Share on other sites

[quote author=raji20 link=topic=112636.msg457272#msg457272 date=1161769833]
[root@place etc]# crontab 0    12    *    10    1-7  /usr/local/lib/php -f /www/htdocs/phpdocs/test/cron.php
[/quote]

What you need to do is [u]edit[/u] /etc/crontab
/etc/crontab is a text file which has a collection of commands in it to execute at specific times.

So open /etc/crontab up with a text editor like so:
[code]
vi /etc/crontab
[/code]

And then add this to the bottom of the file
[code]
0    12    *    10    1-7  /usr/local/lib/php -f /www/htdocs/phpdocs/test/cron.php
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25025-cron-job/#findComment-114151
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.