Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[OT] maledetto script bash [RISOLTO]
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) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
silverfix
Tux's lil' helper
Tux's lil' helper


Joined: 19 Mar 2003
Posts: 146
Location: born: Foggia - now: Bari

PostPosted: Mon Jan 17, 2005 12:57 pm    Post subject: [OT] maledetto script bash [RISOLTO] Reply with quote

Salve,
avevo esigenza di spegnere il pc ogni giorno alle 23.00 usando tranquillamente cron, però se stavo usando il pc non doveva spegnersi.
Così ho fatto uno script bash per l'occasione:
Code:

#!/bin/bash
VAR=`/bin/ps a | /bin/grep -m 1 xfwm4 | /bin/cut -d " " -f16`
#Se xorg è up:
if [ "$VAR" = "--daemon" ]
then
echo > /dev/null
#altrimenti:
else
/sbin/halt
fi


ma non so come funziona e non funziona... :?

idee :?:
_________________
SilverFix - a happy Linux user!


Last edited by silverfix on Mon Jan 17, 2005 1:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
BikE
Guru
Guru


Joined: 21 Dec 2004
Posts: 455
Location: Genova

PostPosted: Mon Jan 17, 2005 1:20 pm    Post subject: Reply with quote

Prova questo:
Code:


#!/bin/bash

if [ -e /tmp/.X0-lock ]
then
        echo "X.org attivo"             
else
        /sbin/halt     
fi
Back to top
View user's profile Send private message
silverfix
Tux's lil' helper
Tux's lil' helper


Joined: 19 Mar 2003
Posts: 146
Location: born: Foggia - now: Bari

PostPosted: Mon Jan 17, 2005 1:38 pm    Post subject: Reply with quote

grazie mille, è proprio quello che cercavo, non sapevo dell'esistenza del file lock.


RISOLTO ! :D
_________________
SilverFix - a happy Linux user!
Back to top
View user's profile Send private message
BikE
Guru
Guru


Joined: 21 Dec 2004
Posts: 455
Location: Genova

PostPosted: Mon Jan 17, 2005 4:22 pm    Post subject: Reply with quote

Usa questo cosi' eviti di usare cron e lo attivi quando vuoi

Code:

#!/bin/bash

INTERVALLO=30
ORA_SPEGNIMENTO=23

for (( ; ; ))
do
        if [ -e /tmp/.X0-lock ]
        then
                echo -e "xorg attivo"
        else
                if [ `date` == *$ORA_SPEGNIMENTO:*:* ]
                then
                        halt
                fi
        fi
        sleep $INTERVALLO
done


Last edited by BikE on Tue Jan 18, 2005 1:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
silverfix
Tux's lil' helper
Tux's lil' helper


Joined: 19 Mar 2003
Posts: 146
Location: born: Foggia - now: Bari

PostPosted: Mon Jan 17, 2005 10:32 pm    Post subject: Reply with quote

grazie!

:wink:
_________________
SilverFix - a happy Linux user!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano 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