php-script als cronjob

Alles, was PHP betrifft, kann hier besprochen werden.

php-script als cronjob

Postby gonzo6969 » 13. January 2004 14:09

wie muß ich den cronjob anlegen, damit ich php-scripts ausführen kann?

thx im voraus
gonzo6969
 
Posts: 14
Joined: 18. July 2003 13:45
Location: augsburg

Postby DJ DHG » 13. January 2004 14:28

Moin Moin

Code: Select all
* * * * *  /pfad/zur/php/datei.php


die * musst du nochdurch die passenden zeiten ändern.

Code: Select all
#!/opt/lampp/bin/php -q


muss in der ersten zeile des php scripts stehn..


beispeil:

Code: Select all
#!/opt/lampp/bin/php -q
<?PHP

echo "hallo welt! ";

?>


mfg DJ DHG
User avatar
DJ DHG
AF Moderator
 
Posts: 2455
Joined: 27. December 2002 13:50
Location: Kiel

supa, funzt alles

Postby gonzo6969 » 13. January 2004 18:07

merci, merci :P
gonzo6969
 
Posts: 14
Joined: 18. July 2003 13:45
Location: augsburg

Postby gonzo6969 » 15. January 2004 12:13

mmh,

wenn ich jetzt das script als root zum testen ohne crontab ausführe kommt:
/opt/lampp/bin/php: bad interpreter: Keine Berechtigung


muß ich jetzt noch irgendwelche rechte ändern

danke nochmals
gonzo6969
 
Posts: 14
Joined: 18. July 2003 13:45
Location: augsburg

Postby DJ DHG » 15. January 2004 15:34

poste bitte mal deinen code..

wenn er zulang ist verlinke ihn bitte.

mfg DJ DHG
User avatar
DJ DHG
AF Moderator
 
Posts: 2455
Joined: 27. December 2002 13:50
Location: Kiel

Postby gonzo6969 » 15. January 2004 16:24

Nichts spektuläres:

#!/opt/lampp/bin/php -q
<?php
// Kopierprogramm für Server
$zeit = time();
// Aktuelle Zeit in Sekunden
$datum = getdate($zeit);
$monat = $datum[mon];
$tag = $datum[mday];

If ($monat <10){$monat ="0".$monat;}
If ($tag < 10){$tag = "0".$tag;}
$heute= $datum[year]."-".$monat."-".$tag;


rename("thumbnail","thumb".$heute);
mkdir("thumbnail",0755);
//unlink ("thumbold/*.*");
?>


aber danke für deine Hilfe
gonzo6969
 
Posts: 14
Joined: 18. July 2003 13:45
Location: augsburg

Postby DJ DHG » 15. January 2004 16:29

hmm funzt bei mir ohne probs.

chmod +x dateiname.php ausgeführt?
kann mit nur schlecht vorstellen das es daran liegt, aber mehr fällt mir
gerade nicht ein...

mfg DJ DHG
User avatar
DJ DHG
AF Moderator
 
Posts: 2455
Joined: 27. December 2002 13:50
Location: Kiel

chmod wars

Postby gonzo6969 » 15. January 2004 18:34

:oops: :oops: asche auf mein haupt :oops: :oops:
Falscher chmod

mit 700 funzt es

Danke für die Mühe
gonzo6969
 
Posts: 14
Joined: 18. July 2003 13:45
Location: augsburg


Return to PHP

Who is online

Users browsing this forum: No registered users and 5 guests