Re[2]: [PHP] Make cron file

2004-09-28 Thread Tom Rogers
Hi,

Wednesday, September 29, 2004, 1:18:20 AM, you wrote:
JB> [snip]
JB> I need make a cron file, for example a .job file:
JB> #mi  hodimeseq  jobcomment
JB> 45   11**  0-5 php -q /home/test/test.php  # Make backup
JB> How can make it?.
JB> [/snip]

JB> Type crontab -e and the cron file will be openedunless you're on a
JB> Windows machine

JB> --
JB> PHP General Mailing List (http://www.php.net/)
JB> To unsubscribe, visit: http://www.php.net/unsub.php


You can do something like this for the web server user:
&1 > /dev/null';
//get existing cron entries
exec('crontab -l',$list);
//add new command
$list[] = $cmd;
//may need to change the server var  for your setup
$path = dirname($_SERVER['PATH_TRANSLATED']).'/cronout';

//create a cronfile
if($fp = fopen($path,"w")){
foreach($list as $line){
$line = trim($line);
fputs($fp,$line."\n");
}
fclose($fp);
}
//tell cron about it
exec("crontab $path");
?>
Note appending to an existing cron file probably will not work as cron
has to be told to re read it and the webserver user can not do that
usually.

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread Maciek Ruckgaber Bielecki
So I understand, correct me if i am wrong, that your problem is just to
append a line to the file ?

if that is the case:
  
  //open and place pointer at the end of the file
  $fhandler = fopen("file",'a'); 
  fputs($fhandler,$string_with_code);
  fclose($fhandler);

if not, the case and you are having bad time trying to explain, i
  understand some spanish, so lets review it ;-)

Cheers
  
  
  On Tue, Sep 28, 2004 at 01:45:09PM -0300, Juan Pablo Herrera wrote:
> sorry, my cuestion is about the construction of the job file with php.
> I send parameters via POST: day, hours, minute, sentence for execuite with
> cron. This is cached for a php file that make the job file. Well, my
> problem is make this php file.I think to use file() for this, but maybe somebody 
> think other idea.
> 
> Regards,
> JP
> 
> > Jay Blanchard wrote:
> >> [snip]
> >> I need make a cron file, for example a .job file:
> >> #mi  hodimeseq  jobcomment 45
> >>  11**  0-5 php -q /home/test/test.php  # Make backup
> >> How can make it?.
> >> [/snip]
> >>
> >> Type crontab -e and the cron file will be openedunless you're on a
> >> Windows machine
> > in both cases, this is the wrong list to ask this.
> >
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 

Maciek Ruckgaber Bielecki



"I never think of the future. It comes soon enough." 
--Albert Einstein--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread Juan Pablo Herrera
sorry, my cuestion is about the construction of the job file with php.
I send parameters via POST: day, hours, minute, sentence for execuite with
cron. This is cached for a php file that make the job file. Well, my
problem is make this php file.I think to use file() for this, but maybe somebody think 
other idea.

Regards,
JP

> Jay Blanchard wrote:
>> [snip]
>> I need make a cron file, for example a .job file:
>> #mi  hodimeseq  jobcomment 45
>>  11**  0-5 php -q /home/test/test.php  # Make backup
>> How can make it?.
>> [/snip]
>>
>> Type crontab -e and the cron file will be openedunless you're on a
>> Windows machine
> in both cases, this is the wrong list to ask this.
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread E SA

Juan,

Are you trying to do so from inside a PHP script?

If that is the case, you could do:

$entry = "$min $h $d $m $s $command $comment";

$added = system ("echo $entry >>
/var/spool/cron/tabs/$user", $retval);

if ($retval) {
echo "success";
} else {
echo "failure";
}

Please notice that the code is not tested!

Let us know if that helped!

-- ES


--- John Nichel <[EMAIL PROTECTED]> wrote:

> Juan Pablo Herrera wrote:
> > Hi!
> > I need make a cron file, for example a .job file:
> > #mi  hodimeseq  job   
> comment
> > 45   11**  0-5 php -q
> /home/test/test.php  # Make backup
> > How can make it?.
> 
> How about asking on the proper list?  Or Google?
> 
> Do we now add Cron to the list what this list
> supports?
> 
> -- 
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 




__
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread Maciek Ruckgaber Bielecki
I do not understand what is the problem, you just add the
the time format as should be and put the following at the beginning of
your script:
#!/usr/local/bin/php -q (or your path to the php interpreter)


then you simply add the line (crontab -e)
0 3  * * * /area_backup/bin/sync.php [args]

hope it helps, and yes, this is probably the wrong list mate ;-)

Cheers,

On Tue, Sep 28, 2004 at 11:47:51AM -0400, John Nichel wrote:
> Juan Pablo Herrera wrote:
> >Hi!
> >I need make a cron file, for example a .job file:
> >#mi  hodimeseq  jobcomment
> >45   11**  0-5 php -q /home/test/test.php  # Make backup
> >How can make it?.
> 
> How about asking on the proper list?  Or Google?
> 
> Do we now add Cron to the list what this list supports?
> 
> -- 
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 

Maciek Ruckgaber Bielecki



"All our lauded technological progress -- our very civilization - is like the axe in 
the hand of the pathological criminal." 
--Albert Einstein--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread John Nichel
Jay Blanchard wrote:
At least he is CRON'ing a php script
Well, we can't have that.  Maybe we can talk the OP to change his 
question...maybe he can ask how to set up a cron to sync his system 
clock with a time server. ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Make cron file

2004-09-28 Thread Jay Blanchard
[snip]
Juan Pablo Herrera wrote:
> Hi!
> I need make a cron file, for example a .job file:
> #mi  hodimeseq  jobcomment
> 45   11**  0-5 php -q /home/test/test.php  # Make
backup
> How can make it?.

How about asking on the proper list?  Or Google?

Do we now add Cron to the list what this list supports?
[/snip]

At least he is CRON'ing a php script

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Make cron file

2004-09-28 Thread John Nichel
Juan Pablo Herrera wrote:
Hi!
I need make a cron file, for example a .job file:
#mi  hodimeseq  jobcomment
45   11**  0-5 php -q /home/test/test.php  # Make backup
How can make it?.
How about asking on the proper list?  Or Google?
Do we now add Cron to the list what this list supports?
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Make cron file

2004-09-28 Thread M. Sokolewicz
Jay Blanchard wrote:
[snip]
I need make a cron file, for example a .job file:
#mi  hodimeseq  jobcomment
45   11**  0-5 php -q /home/test/test.php  # Make backup
How can make it?.
[/snip]
Type crontab -e and the cron file will be openedunless you're on a
Windows machine
in both cases, this is the wrong list to ask this.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Make cron file

2004-09-28 Thread Jay Blanchard
[snip]
I need make a cron file, for example a .job file:
#mi  hodimeseq  jobcomment
45   11**  0-5 php -q /home/test/test.php  # Make backup
How can make it?.
[/snip]

Type crontab -e and the cron file will be openedunless you're on a
Windows machine

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Make cron file

2004-09-28 Thread Juan Pablo Herrera
Hi!
I need make a cron file, for example a .job file:
#mi  hodimeseq  jobcomment
45   11**  0-5 php -q /home/test/test.php  # Make backup
How can make it?.

Regards.
JP

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php