Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #21514 > unrolled thread
| Started by | NoS <NoS@nospam.no> |
|---|---|
| First post | 2017-03-21 08:30 +0100 |
| Last post | 2017-03-21 12:10 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to it.comp.www.php
redirect tramite cron su file php remoto NoS <NoS@nospam.no> - 2017-03-21 08:30 +0100
Re: redirect tramite cron su file php remoto Alessandro Pellizzari <shuriken@amiran.it> - 2017-03-21 11:09 +0000
Re: redirect tramite cron su file php remoto NoS <NoS@nospam.no> - 2017-03-21 12:10 +0100
| From | NoS <NoS@nospam.no> |
|---|---|
| Date | 2017-03-21 08:30 +0100 |
| Subject | redirect tramite cron su file php remoto |
| Message-ID | <oaqkr9$1f5k$1@gioia.aioe.org> |
Buongiorno a tutti,
la situazione è la seguente:
1 - devo lanciare uno script php che esegue alcune operazione e si trova
sul dominio AAA -> http://AAA.com/script.php.
2 - non ho possibilità di settare un CRON su quel server (è un host di
quelli a pochi euro e non me lo consente)
3 - quindi, tramite un altro server (BBB) che gestisco direttamente
avevo pensato di impostare un CRON che chiamasse un file presente su BBB
che andasse a chiamare http://AAA.com/script.php.
In pratica ho creato un file: http://BBB.com/lanciascript.php contenente
<?php
$linkToBackUp = "http://AAA.com/script.php";
header("Location: ".$linkToBackUp);
?>
Cosa succede:
- se da browser chiamo il file http://BBB.com/lanciascript.php tutto va
a buon fine, con il redirect che viene eseguito e viene lanciato
http://AAA.com/script.php.
- se però, imposto un CRON, sul server BBB, il cui compito è eseguire
http://BBB.com/lanciascript.php, l'operazione di CRON viene eseguita ma
la chiamata/redirect non va a buon fine ed il log del CRON mi
restituisce un errore 302.
Sperando d'essermi spiegato.... cosa sto sbagliando?
Grazie in anticipo.
[toc] | [next] | [standalone]
| From | Alessandro Pellizzari <shuriken@amiran.it> |
|---|---|
| Date | 2017-03-21 11:09 +0000 |
| Message-ID | <ejcfv7F2qg7U1@mid.individual.net> |
| In reply to | #21514 |
On 21/03/17 07:30, NoS wrote: > - se però, imposto un CRON, sul server BBB, il cui compito è eseguire > http://BBB.com/lanciascript.php, l'operazione di CRON viene eseguita ma > la chiamata/redirect non va a buon fine ed il log del CRON mi > restituisce un errore 302. 302 non e` un errore. E` una richiesta di redirect al browser. Sul browser ti funziona perche` e` il browser stesso a fare la seconda richiesta in automatico. Su cron no, perche` chiami lo script da CLI e la CLI non ha idea di cosa sia un redirect. Dovresti gestirlo a mano. Su BBB non ti serve uno script PHP. Puoi usare wget o curl per richiamare direttamente lo script su AAA: wget http://aaa.com/script.php Cerca sul manuale di wget e curl come gestire l'output. Di default wget salva su disco, ma puoi redirigerlo a stdout in modo che cron te lo mandi via email, o scartarlo, se non ti interessa. Bye.
[toc] | [prev] | [next] | [standalone]
| From | NoS <NoS@nospam.no> |
|---|---|
| Date | 2017-03-21 12:10 +0100 |
| Message-ID | <oar1nv$7g5$1@gioia.aioe.org> |
| In reply to | #21515 |
Grazie, proverò. Il 21/03/2017 12.09, Alessandro Pellizzari ha scritto: > On 21/03/17 07:30, NoS wrote: > >> - se però, imposto un CRON, sul server BBB, il cui compito è eseguire >> http://BBB.com/lanciascript.php, l'operazione di CRON viene eseguita ma >> la chiamata/redirect non va a buon fine ed il log del CRON mi >> restituisce un errore 302. > > 302 non e` un errore. E` una richiesta di redirect al browser. > > Sul browser ti funziona perche` e` il browser stesso a fare la seconda > richiesta in automatico. > > Su cron no, perche` chiami lo script da CLI e la CLI non ha idea di cosa > sia un redirect. Dovresti gestirlo a mano. > > Su BBB non ti serve uno script PHP. > Puoi usare wget o curl per richiamare direttamente lo script su AAA: > > wget http://aaa.com/script.php > > Cerca sul manuale di wget e curl come gestire l'output. Di default wget > salva su disco, ma puoi redirigerlo a stdout in modo che cron te lo > mandi via email, o scartarlo, se non ti interessa. > > Bye. > >
[toc] | [prev] | [standalone]
Back to top | Article view | it.comp.www.php
csiph-web