Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[RISOLTO] halt in crontab
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
funkoolow
Guru
Guru


Joined: 21 Sep 2004
Posts: 545
Location: er paese delle anguille

PostPosted: Tue Jan 25, 2011 2:11 pm    Post subject: [RISOLTO] halt in crontab Reply with quote

salve a tutti,
avendo necessità di impostare lo spegnimento automatico di una macchina ogni due giorni ad una certa ora, ho impostato la riga seguente con crontab -e (da root, ovviamente):
Code:

00 03 */2 * * halt
15 03 */2 * * date >> /root/test.txt

al contrario di quanto succede al file /root/test.txt, al quale ogni due giorni alle 3:15 viene regolarmente aggiunto il record dell'output di date (confermandomi che la sintassi crontab su cui nutrivo qualche dubbio è giusta), il comando halt non viene mai eseguito, lasciando la macchina sempre accesa.

qualcuno mi sa dire dove sbaglio? grazie tutti in anticipo come sempre :)
_________________
SabaziaLUG: il LUG a nord di Roma


Last edited by funkoolow on Thu Jan 27, 2011 1:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
cloc3
Advocate
Advocate


Joined: 13 Jan 2004
Posts: 4788
Location: http://www.gentoo-users.org/user/cloc3/

PostPosted: Tue Jan 25, 2011 2:50 pm    Post subject: Reply with quote

ipotesi da verificare (magari nei log)
halt appartiene al percorso /sbin che non è riconosciuto da chron.
prova a inserire il perrorso completo.
_________________
vu vu vu
gentù
mi piaci tu
Back to top
View user's profile Send private message
funkoolow
Guru
Guru


Joined: 21 Sep 2004
Posts: 545
Location: er paese delle anguille

PostPosted: Tue Jan 25, 2011 4:10 pm    Post subject: Reply with quote

grazie per la risposta, questo è il mio messages greppato su halt
Code:
funkserver funkoolow # cat /var/log/messages | grep halt
Jan 21 02:00:01 funkserver cron[13466]: (root) CMD (halt)
Jan 23 02:00:01 funkserver cron[25498]: (root) CMD (halt)
Jan 25 02:00:01 funkserver cron[9789]: (root) CMD (halt)

da quanto posso capire, mi pare che il comando venga preso in considerazione (l'ora è diversa perchè ho cambiato il codice subito prima del post precedente)... dove guardo eventuali errori in output del cron (che magari spiegano perchè poi in effetti la macchina non si spegne)? intanto ho impostato il percorso completo come mi hai suggerito, posterò l'esito dopo giovedì, per ora grazie ancora :)
_________________
SabaziaLUG: il LUG a nord di Roma
Back to top
View user's profile Send private message
cloc3
Advocate
Advocate


Joined: 13 Jan 2004
Posts: 4788
Location: http://www.gentoo-users.org/user/cloc3/

PostPosted: Tue Jan 25, 2011 4:29 pm    Post subject: Reply with quote

magari, se hai fretta di darti una risposta rapida, puoi sostituire al posto del comando date un echo $PATH o un env, in modo da capire come si comporta cron.

inoltre puoi redigere anche l'output di halt verso file, per raccogliere eventuali errori.
_________________
vu vu vu
gentù
mi piaci tu
Back to top
View user's profile Send private message
lele_dj
Tux's lil' helper
Tux's lil' helper


Joined: 09 May 2007
Posts: 86

PostPosted: Tue Jan 25, 2011 5:00 pm    Post subject: Reply with quote

magari dico una bagianata ma potresti provare a farti uno script per spegnere il PC e al posto di inserire direttamente il comando in cron fai lanciare lo script
Back to top
View user's profile Send private message
xdarma
l33t
l33t


Joined: 08 Dec 2003
Posts: 719
Location: tra veneto e friuli (italy)

PostPosted: Tue Jan 25, 2011 8:20 pm    Post subject: Re: halt in crontab Reply with quote

Prova a modificare la riga /etc/crontab così:
Code:

00 03 */2 * * root halt -f

_________________
proud user of faKeDE-4.7.3 -> back to windowmaker -> moved to LXQt
Back to top
View user's profile Send private message
djinnZ
Advocate
Advocate


Joined: 02 Nov 2006
Posts: 4831
Location: somewhere in L.O.S.

PostPosted: Wed Jan 26, 2011 3:10 pm    Post subject: Reply with quote

a parte l'opzione alternativa di un banalissimo
Code:
sleep `echo \`date -d "2011-01-28 16:00" +%s\`-\`date +%s\` | bc` ; halt
e variazioni sul tema, rifletterei su questo
il solito F****** manuale - man halt wrote:
From release 2.74 on halt and reboot invoke shutdown...
, prova a chiamare direttamente shutdown -h now così capisci meglio cosa è successo ma a naso credo che halt non riesca a rilevare del tutto il runlevel e quindi chiami shutdown che a sua volta volta si ferma perchè non trova nessun utonto loggato.

Se lo devi lasciare attivo per web server o solo per scaricare qualcosa penserei ad usar direttamente
Code:
shutdown -h `echo \`date -d "2011-01-28 16:00" +%s\`-\`date +%s\` | bc`
così previeni anche i login.
_________________
scita et risus abundant in ore stultorum sed etiam semper severi insani sunt:wink:
mala tempora currunt...mater stultorum semper pregna est :evil:
Murpy'sLaw:If anything can go wrong, it will - O'Toole's Corollary:Murphy was an optimist :wink:
Back to top
View user's profile Send private message
funkoolow
Guru
Guru


Joined: 21 Sep 2004
Posts: 545
Location: er paese delle anguille

PostPosted: Thu Jan 27, 2011 1:44 pm    Post subject: Reply with quote

grazie a tutti per i sempre ottimi suggerimenti, sembra che aggiungere il percorso completo sia stato efficace :)
proverò a fare qualche altro test con le altre soluzioni, per ora taggo risolto e vi saluto!
_________________
SabaziaLUG: il LUG a nord di Roma
Back to top
View user's profile Send private message
MajinJoko
l33t
l33t


Joined: 20 Sep 2005
Posts: 639
Location: Bergamo / Verona

PostPosted: Mon Feb 28, 2011 10:23 am    Post subject: Reply with quote

Stavo facendo la stessa cosa.

Un dubbio. Una volta inserito il crontab con crontab -e, è un comportamento corretto quello che ottengo, cioé che il comando viene eseguito solo se riavvio vixie-cron dopo il salvataggio del nuovo crontab?
_________________
[(.. watashi wa Urumi Kanzaki ga suki da ..)]
Back to top
View user's profile Send private message
xdarma
l33t
l33t


Joined: 08 Dec 2003
Posts: 719
Location: tra veneto e friuli (italy)

PostPosted: Mon Feb 28, 2011 8:14 pm    Post subject: Reply with quote

MajinJoko wrote:
Un dubbio. Una volta inserito il crontab con crontab -e, è un comportamento corretto quello che ottengo, cioé che il comando viene eseguito solo se riavvio vixie-cron dopo il salvataggio del nuovo crontab?

Non è corretto, secondo man crontab:
Quote:
The -e option is used to edit the current crontab using the editor spec‐
ified by the VISUAL or EDITOR environment variables. After you exit
from the editor, the modified crontab will be installed automatically.

Ma penso che riavviare con /etc/init.d/vixie-cron restart non sia un gran problema.
_________________
proud user of faKeDE-4.7.3 -> back to windowmaker -> moved to LXQt
Back to top
View user's profile Send private message
MajinJoko
l33t
l33t


Joined: 20 Sep 2005
Posts: 639
Location: Bergamo / Verona

PostPosted: Tue Mar 01, 2011 9:05 am    Post subject: Reply with quote

orpo, infatti qualcosa mica torna..
_________________
[(.. watashi wa Urumi Kanzaki ga suki da ..)]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum