Prijava
Korisničko ime:

Lozinka:

remember me

Zaboravili lozinku?

Registrirajte se!
Glavni menu
Potraga
Tko je online
8 korisnika je online (2 korisnika cita Diskusije)

članovi: 0
Gosti: 8

više...
HULK-Diskusije - Linux općenito - Omanila skripta
Chat WIKI Kontakt
HULK Forum Index
   Linux općenito
  Omanila skripta

Pregledavanje ovog Threada:   1 Anonimnih Korisnika

 

 Dno   Prethodna tema   Sljedeca tema
12345>
  •  Ocjena Threada
      Ocijenite ovaj Thread
      Izvrsno
      Dobro
      Prosjecno
      Loše
      Užasno
Pošiljatelj Thread
Omanila skripta
#1
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Imam skriptu koju izvodim svaki dan u 17.00 preko krona. Evo je:

#!/bin/bash
mpg123 /home/davor/linux/bckp/zvk/gong.mp3
cp /home/davor/linux/bckp/slk/bckp.gif /home/davor/Desktop
cp /home/davor/linux/bckp/kad.txt /home/davor/linux/bckp/kad-old.txt
echo $(date) > /home/davor/linux/bckp/kad.txt
cd /media/bckp
echo "Backup"
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Lekcije"
cp /home/davor/linux/bckp/slk/lkcj.gif /home/davor/Desktop
rm -fr Lekcije
cp /home/davor/Lekcije /media/bckp -R
rm /home/davor/Desktop/lkcj.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "linux"
cp /home/davor/linux/bckp/slk/lnx.gif /home/davor/Desktop
rm -fr linux
cp /home/davor/linux /media/bckp -R
rm /home/davor/Desktop/lnx.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Razno"
cp /home/davor/linux/bckp/slk/rzn.gif /home/davor/Desktop
rm -fr Razno
cp /home/davor/Razno /media/bckp -R
rm /home/davor/Desktop/rzn.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Slike"
cp /home/davor/linux/bckp/slk/slk.gif /home/davor/Desktop
rm -fr Slike
cp /home/davor/Slike /media/bckp -R
rm /home/davor/Desktop/slk.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Web"
cp /home/davor/linux/bckp/slk/wb.gif /home/davor/Desktop
rm -fr Web
cp /home/davor/Web /media/bckp -R
rm /home/davor/Desktop/wb.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Obrada"
cp /home/davor/linux/bckp/slk/obr.gif /home/davor/Desktop
rm -fr Obrada
cp /home/davor/Obrada /media/bckp -R
rm /home/davor/Desktop/obr.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Spremi"
cp /home/davor/linux/bckp/slk/spr.gif /home/davor/Desktop
rm -fr Spremi
cp /home/davor/Spremi /media/bckp -R
rm /home/davor/Desktop/spr.gif
#echo "Download"
#cp /home/davor/linux/bckp/slk/dwn.gif /home/davor/Desktop
#rm -fr Download
#mkdir Download
#cp /home/davor/Download/00000 /media/bckp/Download -R
#cp /home/davor/Download/zzzzz /media/bckp/Download -R
#rm /home/davor/Desktop/dwn.gif
echo $(date) >> /home/davor/linux/bckp/kad.txt
rm /home/davor/Desktop/bckp.gif
echo "Gotovo"
a=`date | awk '{print $1}'`
if [ "$a" == "Sun" ]; then
cp /home/davor/linux/bckp/slk/bckp.gif /home/davor/Desktop
#zenity --notification --text=backup_počinje
cp /home/davor/linux/bckp/kad.txt /home/davor/linux/bckp/kad-old.txt
echo $(date) > /home/davor/linux/bckp/kad.txt
#sudo mount /dev/sdc1 /media/store
cd /media/store
echo "Backup"
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Lekcije"
cp /home/davor/linux/bckp/slk/lkcj.gif /home/davor/Desktop
rm -fr Lekcije
cp /media/bckp/Lekcije /media/store -R
rm /home/davor/Desktop/lkcj.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "linux"
cp /home/davor/linux/bckp/slk/lnx.gif /home/davor/Desktop
rm -fr linux
cp /media/bckp/linux /media/store -R
rm /home/davor/Desktop/lnx.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Razno"
cp /home/davor/linux/bckp/slk/rzn.gif /home/davor/Desktop
rm -fr Razno
cp /media/bckp/Razno /media/store -R
rm /home/davor/Desktop/rzn.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Slike"
cp /home/davor/linux/bckp/slk/slk.gif /home/davor/Desktop
rm -fr Slike
cp /media/bckp/Slike /media/store -R
rm /home/davor/Desktop/slk.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Web"
cp /home/davor/linux/bckp/slk/wb.gif /home/davor/Desktop
rm -fr Web
cp /media/bckp/Web /media/store -R
rm /home/davor/Desktop/wb.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Obrada"
cp /home/davor/linux/bckp/slk/obr.gif /home/davor/Desktop
rm -fr Obrada
cp /media/bckp/Obrada /media/store -R
rm /home/davor/Desktop/obr.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Spremi"
cp /home/davor/linux/bckp/slk/spr.gif /home/davor/Desktop
rm -fr Spremi
cp /media/bckp/Spremi /media/store -R
rm /home/davor/Desktop/spr.gif
#echo "Download"
#cp /home/davor/linux/bckp/slk/dwn.gif /home/davor/Desktop
#rm -fr Download
#mkdir Download
#cp /media/bckp/Download/00000 /media/store/Download -R
#cp /media/bckp/Download/zzzzz /media/store/Download -R
#rm /home/davor/Desktop/dwn.gif
echo $(date) >> /home/davor/linux/bckp/kad.txt
rm /home/davor/Desktop/bckp.gif
echo "Gotovo"
fi
mpg123 /home/davor/linux/bckp/zvk/gong.mp3
#zenity --warning --text=backup_gotov

Radila je bez greške do danas. Jednostavno je stala u sred posla. Na kompu se nije radilo, na ekranu je bio screensaver i svirao je audacious. Postoji li načinm da saznam što je bilo?

Još jedno pitanje. Pokušao sam skriptu izvesti ručno u shellu. Odradila je sve bez problema. Međutim u djelu u kom detektiram nedjelju kod pokretanja cronom treba pisati Sun, a kod ručnog Ned. Na kompu mi je ubuntu na hrv. jeziku.

treće, ima li ubuntu ili debian alat za pregledavanje logova kao što ima mandriva?
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 01.08.2010 12:19:35
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#2
Linux Master
Pridružen: 04.01.2005
Od 33 stupnja i 4 minute sjeverno, i zatim 5 koraka na zapad
Poruke: 2390
Level : 39
HP : 192 / 963
MP : 796 / 28032
EXP : 55
Grupa:
Webmasters
Registered Users
HULK
UrednikNovosti
UrednikRecenzija
UrednikLinkova
ModeratoriForuma
UrednikSekcija
UrednikBlogova
UrednikDogadjanja
UrednikDokumenata
UrednikKomentara
Offline
Alat za pregledanje logova? Imaš less/more, tail, head, grep, awk, sed, i moš na netu potražit raznorazne log colorizere. Ako misliš na GUI, nemam pojma ni kako to ima mandriva ni što ima kao ekvivalent ubuntu.

Kod ove tvoje greške ja bi prvo pogledao cron logove.
_________________
Poći ću s vama jer volim šalu, hoću da vidim ježa budalu.

Put u Japan
Postano : 02.08.2010 5:08:28
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#3
Linuxaš wanna-be
Pridružen: 14.10.2008
Od Hrvacka
Poruke: 26
Level : 3
HP : 0 / 70
MP : 8 / 1278
EXP : 83
Grupa:
Registered Users
Offline
Ovo da ti naredba date drugačije radi iz shella i iz crona nije niš čudno, jer cron ne koristi isti environment kao i shell. Recimo cron ne sourca /etc/profile i to.

Pokreni je sa engleskim localeom, npr.

LC_ALL="en_US" /staza/do/skripta.sh

A što se tiče ovog prvog pitanja, vidiš li barem na kojoj je naredbi stala skripta? Malo više logiranja bi možda trebao dodati.
Kako vidiš da je stala usred posla? Da li ostane proces visiti?
Postano : 02.08.2010 5:45:26
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#4
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Hvala na odgovorima. Nisam ništa pametniji.
Slobodane, cron je uredno pokremuo skriptu ko i svaki dan i na njega nemam zamjerku.
Skripta je stala u djelu koji se izvršava nedjeljom nakon kopiranja direktorija linux. Ko šta vidite skripta samo kopira i ima zvučnu i vizualnu dojavu rada.
Neznam zašto je stala iz čista mira. Gledam logove i ne nalazim ništa pametno. Viditi ću danas u 17 šta će biti.
Našao sam gui za logove: ksystemlog
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 02.08.2010 9:39:31
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#5
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Skripta odradila. Međutim jučer je stala u 'nedjeljnom' djelu taklo da ću još pratiti u sljedeću nedjelju.
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 02.08.2010 12:09:33
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#6
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Danas je sve ok.
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 08.08.2010 11:40:12
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#7
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Opet skripta stala iz čista mira. Pokrenuo sam je zatim ručno i pratio u shellu. Odradila je ko švicarski sat. Oba zastoja su bila na Ubuntu. Treba li se ostaviti Ubuntua i koristiti nešto drugo?
Kod oba zastoja stroj nije bio opterećen. A kako sam dorađivao skriptu opet je pejstam. Svaki konstruktivni komentar je dobro došao.
Skripta:

#!/bin/bash
mpg123 /home/davor/linux/bckp/zvk/zahod.mp3
cp /home/davor/linux/bckp/slk/bckp.gif /home/davor/Desktop
cp /home/davor/linux/bckp/kad.txt /home/davor/linux/bckp/kad-old.txt
echo $(date) > /home/davor/linux/bckp/kad.txt
cd /media/store
echo "Backup"
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Lekcije"
cp /home/davor/linux/bckp/slk/lkcj.gif /home/davor/Desktop
rm -fr Lekcije
cp /home/davor/Lekcije /media/store -R
rm /home/davor/Desktop/lkcj.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "linux"
cp /home/davor/linux/bckp/slk/lnx.gif /home/davor/Desktop
rm -fr linux
cp /home/davor/linux /media/store -R
rm /home/davor/Desktop/lnx.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Razno"
cp /home/davor/linux/bckp/slk/rzn.gif /home/davor/Desktop
rm -fr Razno
cp /home/davor/Razno /media/store -R
rm /home/davor/Desktop/rzn.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Slike"
cp /home/davor/linux/bckp/slk/slk.gif /home/davor/Desktop
rm -fr Slike
cp /home/davor/Slike /media/store -R
rm /home/davor/Desktop/slk.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Web"
cp /home/davor/linux/bckp/slk/wb.gif /home/davor/Desktop
rm -fr Web
cp /home/davor/Web /media/store -R
rm /home/davor/Desktop/wb.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Obrada"
cp /home/davor/linux/bckp/slk/obr.gif /home/davor/Desktop
rm -fr Obrada
cp /home/davor/Obrada /media/store -R
rm /home/davor/Desktop/obr.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Spremi"
cp /home/davor/linux/bckp/slk/spr.gif /home/davor/Desktop
rm -fr Spremi
cp /home/davor/Spremi /media/store -R
rm /home/davor/Desktop/spr.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Download"
cp /home/davor/linux/bckp/slk/dwn.gif /home/davor/Desktop
rm -fr Download
mkdir Download
cp /home/davor/Download/00000 /media/store/Download -R
#cp /home/davor/Download/Sibenik-rat /media/store/Download -R
#cp /home/davor/Download/Alan_Ford /media/store/Download -R
rm /home/davor/Desktop/dwn.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Glazba"
cp /home/davor/linux/bckp/slk/glz.gif /home/davor/Desktop
cd /media/home2/Glazba
ls * -d | while read f
do
if [ ! -d /media/store/Glazba/$f ]
then
cp /media/home2/Glazba/$f /media/store/Glazba/ -R
else
cd /media/home2/Glazba/$f
ls > /home/davor/.glh.txt
cd /media/store/Glazba/$f
ls > /home/davor/.gls.txt
cmp /home/davor/.glh.txt /home/davor/.gls.txt > /dev/null
if [ $? -eq 1 ]
then
rm -fr /media/store/Glazba/$f
cp /media/home2/Glazba/$f /media/store/Glazba/ -R
fi
rm /home/davor/.glh.txt /home/davor/.gls.txt
fi
done

rm /home/davor/Desktop/glz.gif
mpg123 /home/davor/linux/bckp/zvk/apert.mp3
echo "Video"
cp /home/davor/linux/bckp/slk/vid.gif /home/davor/Desktop
cd /media/home2/Video
ls * -d | while read f
do
v=`ls -dl $f`
#echo $v
v=$(echo ${v:0:1})
#echo $v
if [ "$v" = "d" ]
then
if [ "$f" != "Porno" ]
then
if [ ! -d /media/store/Video/$f ]
then
cp /media/home2/Video/$f /media/store/Video/ -R
else
cd /media/home2/Video/$f
ls > /home/davor/.glh.txt
cd /media/store/Video/$f
ls > /home/davor/.gls.txt
cmp /home/davor/.glh.txt /home/davor/.gls.txt > /dev/null
if [ $? -eq 1 ]
then
rm -fr /media/store/Video/$f
cp /media/home2/Video/$f /media/store/Video/ -R
fi
cd /media/home2/Video
rm /home/davor/.glh.txt /home/davor/.gls.txt
fi
fi
fi
if [ "$v" = "-" ]
then
if [ ! -f /media/store/Video/$f ]
then
cp /media/home2/Video/$f /media/store/Video/
fi
fi
done

cd /media/home2/Video/Porno
ls * -d | while read f
do
v=`ls -dl $f`
#echo $v
v=$(echo ${v:0:1})
#echo $v
if [ "$v" = "d" ]
then
if [ ! -d /media/store/Video/Porno/$f ]
then
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/ -R
else
cd /media/home2/Video/Porno/$f
ls > /home/davor/.glh.txt
cd /media/store/Video/Porno/$f
ls > /home/davor/.gls.txt
cmp /home/davor/.glh.txt /home/davor/.gls.txt > /dev/null
if [ $? -eq 1 ]
then
rm -fr /media/store/Video/Porno/$f
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/ -R
fi
cd /media/home2/Video/Porno
rm /home/davor/.glh.txt /home/davor/.gls.txt
fi
fi
if [ "$v" = "-" ]
then
if [ ! -f /media/store/Video/Porno/$f ]
then
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/
fi
fi
done
rm /home/davor/Desktop/vid.gif
echo Gotovo
echo $(date) >> /home/davor/linux/bckp/kad.txt
rm /home/davor/Desktop/bckp.gif
mpg123 /home/davor/linux/bckp/zvk/zahod.mp3
#zenity --warning --text=backup_gotov
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 01.10.2010 11:53:03
Izradi PDF od ove poruke Ispis
Vrh
  •  wrapper
      wrapper
Re: Omanila skripta
#8
Upravo došao
Pridružen: 01.01.2005
Od
Poruke: 2
Level : 1
HP : 0 / 0
MP : 0 / 19
EXP : 2
Grupa:
Registered Users
Offline
Bok!
Mozes pokusati pozvati bash u debug modu i pogledati sto se dogadja.

# Start in debug mode and Send stderr to file
$bash -x script.sh 2> log.txt

Poslije pogledaj \"log.txt\" za greske.


Ako ne zelis cijeli skript provjeravati, mozes provjeriti
samo dio koda.

Debugging part of a script:

set -x # activate debugging
# your commands go here...
set +x # stop debugging


$./script.sh 2> log.txt


Takodjer, mozes pogledati MAN \"set\" za jos opcija.

set -n, provjera sintakse bez izvrsenja
set -t
set -v
Postano : 01.10.2010 16:02:44
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#9
Upravo došao
Pridružen: 17.02.2010
Od
Poruke: 12
Level : 2
HP : 0 / 31
MP : 4 / 443
EXP : 25
Grupa:
Registered Users
UrednikNovosti
UrednikRecenzija
UrednikLinkova
UrednikSekcija
UrednikDogadjanja
Offline
Citat:



cd /media/home2/Video/Porno
ls * -d | while read f
do
v=`ls -dl $f`
#echo $v
v=$(echo ${v:0:1})
#echo $v
if [ "$v" = "d" ]
then
if [ ! -d /media/store/Video/Porno/$f ]
then
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/ -R
else
cd /media/home2/Video/Porno/$f
ls > /home/davor/.glh.txt
cd /media/store/Video/Porno/$f
ls > /home/davor/.gls.txt
cmp /home/davor/.glh.txt /home/davor/.gls.txt > /dev/null
if [ $? -eq 1 ]
then
rm -fr /media/store/Video/Porno/$f
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/ -R
fi
cd /media/home2/Video/Porno
rm /home/davor/.glh.txt /home/davor/.gls.txt
fi
fi
if [ "$v" = "-" ]
then
if [ ! -f /media/store/Video/Porno/$f ]
then
cp /media/home2/Video/Porno/$f /media/store/Video/Porno/
fi
fi
done


Postano : 02.10.2010 4:10:00
Izradi PDF od ove poruke Ispis
Vrh
Re: Omanila skripta
#10
Linux Master
Pridružen: 29.12.2005
Od Šibenik
Poruke: 787
Level : 25
HP : 0 / 607
MP : 262 / 15913
EXP : 28
Grupa:
Registered Users
Offline
Wraperu, puno ti hvala za ove upute. Proučiti ću. Linux me stalno iznenađuje i oduševljava svojim mogućnostima. Bar da na ovom forumu ima više postova preko kojih se upoznaje OS. Ja o mogućnostima Linuxa neznam ništa, a volio bih znati.

Vučiniću, sivi tiću, ko je bez grijeha nek prvi baci kamen. Ja iman dojam da ti mene jako voliš. Ajmo ti ija biti dobri prijatelji. Može li?
_________________
-- Davor R. Bergam
Experiments, no experiences!!

Svijet Linuxa
Postano : 02.10.2010 8:07:14
Izradi PDF od ove poruke Ispis
Vrh
 Vrh   Prethodna tema   Sljedeca tema
12345>

 


 Ne možete pokrenuti novu temu.
 Možete citati teme.
 Ne možete odgovarati na poruke.
 Ne možete uredivati svoje poruke.
 Ne možete brisati svoje poruke.
 Ne možete dodavati nove ankete.
 Ne možete glasati u anketama.
 Ne možete dodavati fileove porukama.
 Ne možete slati poruke bez odobrenja.
Copyright © 1995-2009 HULK web team. Sva prava pridržana. RSS. Engine: XOOPS