zuviele Prozesse /USR/SBIN/CRON

Du kommst mit der Installation nicht voran oder willst noch was nachfragen? Schau auch in den "Tipps und Tricks"-Bereich.
Antworten
rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 05.10.2009 17:48:04

Hallo User,

ich habe mit "erschrecken" festgestellt, dass ich nach dem eintragen dieses Cron-Jobs:

Code: Alles auswählen

* 22 * * 3 wget -O/dev/null http://domain.tld/buli/extern/reminder.php?pw=cron
* * * * 1,4 wget -O/dev/null http://domain.tld/buli/extern/terminplan.php?pw=cronpw
15,30,45 22 * * 5 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
15,20,25,30,40,45 17,20 * * 6 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
10,5,55 17,18,19 * * 7 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
* 20,21,22 * * 5 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
* 15,16,17,18,19,20 * * 6 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
* 15,16,17,18,19 * * 7 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
über den Befehl crontab -e habe ich diese erstellt.
Wenn ich über den Befehl ps aux meine Prozesse anschaue habe ich unzählige Prozesse "/USR/SBIN/CRON".

Wie kann ich diese reduzieren? Ist das ein Bug oder habe ich da "Mist" gebaut?

Vielen Dank für Eure Mühe!!

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rendegast » 05.10.2009 18:49:50

* 22 * * 3 wget -O/dev/null http://domain.tld/buli/extern/reminder.php?pw=cron
* * * * 1,4 wget -O/dev/null http://domain.tld/buli/extern/terminplan.php?pw=cronpw
15,30,45 22 * * 5 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
15,20,25,30,40,45 17,20 * * 6 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
10,5,55 17,18,19 * * 7 wget -O/dev/null http://domain.tld/buli/extern/results.php?pw=cronpw
* 20,21,22 * * 5 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
* 15,16,17,18,19,20 * * 6 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
* 15,16,17,18,19 * * 7 wget -O/dev/null http://domain.tld/buli/extern/liveresults.php?pw=cronpw
* * * * 1,4 ......
jede Minute an Montag und Donnerstag?
15,20,25,30,40,45 .....
würde ich '15-45/5' schreiben.
10,5,55 17,18,19 * * 7 .....
'10,5,55' funktioniert wie '5,10,55'?

Code: Alles auswählen

wget -O/dev/null http://domain.tld/buli/extern/BLAPAGE.php?pw=cronpw
ungequoted, da koennte das "?" Probleme machen.

Außerdem sollten die Möglichkeiten zum timeout und wait für wget genutzt werden,
vielleicht warten die Prozesse ja auf timeouts für wget und sammeln sich dadurch an?




------------------------------------------------
'http://....pw=cronpw' scheint mir nicht sehr sicher,
einerseits sind die Prozesse in der Prozeßliste sichtbar,
andererseits werden sie so im Internet übertragen.


Ich schlage noch eine solche Lösung zur Übersichtlichkeit vor:

Code: Alles auswählen

...
* * * * 1,4 WGETTER.sh BLAPAGE
... 
mit WGETTER.sh :

Code: Alles auswählen

#!/bin/sh
THIS="$1"
wget -O/dev/null "http://domain.tld/buli/extern/${THIS}.php?pw=cronpw"
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 05.10.2009 20:44:49

wie könnte ich das umgehen? ich zitiere mal: "Außerdem sollten die Möglichkeiten zum timeout und wait für wget genutzt werden,
vielleicht warten die Prozesse ja auf timeouts für wget und sammeln sich dadurch an?"

bin quasi ein linux "neuling" aber nicht gaaaaanz blöd! :D

wie würde ich das mit der /bin/sh genau machen.

beschreib mal genau wie du das machen würdest. würde das gern ausprobieren...

gruß und vielen dank im vorraus!

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rendegast » 05.10.2009 22:01:55

Aus 'man wget':
-t number
--tries=number
Set number of retries to number. Specify 0 or inf for infinite retrying. The default is to retry 20 times, with the exception of fatal errors like ''connection refused'' or ''not found'' (404), which are not retried.
-T seconds
--timeout=seconds
Set the network timeout to seconds seconds. This is equivalent to specifying --dns-timeout, --connect-timeout, and --read-timeout, all at the same time.

When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings.

All timeout-related options accept decimal values, as well as subsecond values. For example, 0.1 seconds is a legal (though unwise) choice of timeout. Subsecond timeouts are useful for checking server response times or for testing network latency.
--dns-timeout=seconds
Set the DNS lookup timeout to seconds seconds. DNS lookups that don't complete within the specified time will fail. By default, there is no timeout on DNS lookups, other than that implemented by system libraries.
--connect-timeout=seconds
Set the connect timeout to seconds seconds. TCP connections that take longer to establish will be aborted. By default, there is no connect timeout, other than that implemented by system libraries.
--read-timeout=seconds
Set the read (and write) timeout to seconds seconds. The ''time'' of this timeout refers idle time: if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted. This option does not directly affect the duration of the entire download.

Of course, the remote server may choose to terminate the connection sooner than this option requires. The default read timeout is 900 seconds.
900 Sekunden stehen da im Raum.
-w seconds
--wait=seconds
Wait the specified number of seconds between the retrievals. Use of this option is recommended, as it lightens the server load by making the requests less frequent. Instead of in seconds, the time can be specified in minutes using the "m" suffix, in hours using "h" suffix, or in days using "d" suffix.

Specifying a large value for this option is useful if the network or the destination host is down, so that Wget can wait long enough to reasonably expect the network error to be fixed before the retry. The waiting interval specified by this function is influenced by "--random-wait", which see.
--waitretry=seconds
If you don't want Wget to wait between every retrieval, but only between retries of failed downloads, you can use this option. Wget will use linear backoff, waiting 1 second after the first failure on a given file, then waiting 2 seconds after the second failure on that file, up to the maximum number of seconds you specify. Therefore, a value of 10 will actually make Wget wait up to (1 + 2 + ... + 10) = 55 seconds per file.

Note that this option is turned on by default in the global wgetrc file.
--random-wait
Some web sites may perform log analysis to identify retrieval programs such as Wget by looking for statistically significant similarities in the time between requests. This option causes the time between requests to vary between 0.5 and 1.5 * wait seconds, where wait was specified using the --wait option, in order to mask Wget's presence from such analysis.

A 2001 article in a publication devoted to development on a popular consumer platform provided code to perform this analysis on the fly. Its author suggested blocking at the class C address level to ensure automated retrieval programs were blocked despite changing DHCP-supplied addresses.

The --random-wait option was inspired by this ill-advised recommendation to block many unrelated users from a web site due to the actions of one.
In der Art:

Code: Alles auswählen

[/Pfad/]wget --tries=2 --timeout=2 --wait=2 [--quiet|--no-verbose].......
Ein fehlgeschlagener Versuch wäre dann nach ~ 10sec beendet.




--------------------------------
* * * * 1,4 WGETTER.sh BLAPAGE
WGETTER.sh müßte Pfad-erreichbar sein, vielleicht in /usr/local/bin ?
Wenn cron das nicht mitmacht, dann einfach mit Pfad angeben:

Code: Alles auswählen

* * * * 1,4 /Pfad/WGETTER.sh BLAPAGE
$1 ist der erste übergebene Parameter, in diesem Fall "BLAPAGE",
die Ersetzung 'THIS="$1"' mache ich, da ich nicht weiß wie "BLAPAGE" letztendlich aussieht und ich es daher quoten wollte,
und aus Unsicherheit sollte ein Konstrukt
"http://...../'$1'...." oder
"http://...../${1}..." vermieden werden.
(In testing-squeeze wurde kürzlich die POSIX-legere bash-sh durch die POSIX-strenge dash ersetzt
und dadurch fand ich einige POSIX-inkompatible Angewohnheiten in meinen (bash-)sh-Skripten)
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 05.10.2009 22:10:15

ich bedanke mich erstmal für deinen ausführlichen post! werde morgen abend mal ausprobieren, ob ich es hinbekomme.
danke schön für deine hilfe.

gruß

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 06.10.2009 16:15:49

also nochmal fürs verständnis:

Ich erstelle in usr/local/sbin eine .sh datei mit meinen cronjobs. beispiel:
#!/bin/sh
THIS="$1"

wget --tries=2 --timeout=2 --wait=2 [--quiet|--no-verbose] -O/dev/null http://domain.tld/buli/extern/BLAPAGE.php?pw=cronpw
usw.
usw.
dann erstell ich einen cronjob mit:

Code: Alles auswählen

* * * * 1,4 WGETTER.sh BLAPAGE
* * * * 1,4 WGETTER.sh BLAPAGE2
usw.
Ich hoffe ich komm nicht all zu verpeilt rüber, habe mich jedoch mit so etwas noch nie beschäftigt!

mfg

uname
Beiträge: 12508
Registriert: 03.06.2008 09:33:02

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von uname » 06.10.2009 16:35:50

Ich würde immer absolute Pfade nutzen, auch wenn es nicht wirklich notwendig ist:

Code: Alles auswählen

* * * * 1,4 /usr/bin/wgetter.sh BLAPAGE
Ausführrechte nicht vergessen:

Code: Alles auswählen

chmod 755 /usr/bin/wgetter.sh
Auch würde ich wie geschrieben Kleinbuchstaben nutzen. Sieht schöner aus.

nepos
Beiträge: 5238
Registriert: 05.01.2005 10:08:12

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von nepos » 06.10.2009 17:03:32

uname hat geschrieben:Ausführrechte nicht vergessen:

Code: Alles auswählen

chmod 755 /usr/bin/wgetter.sh
Auch würde ich wie geschrieben Kleinbuchstaben nutzen. Sieht schöner aus.
Das wäre nun sehr kontraproduktiv. Man sieht das Passwort zwar nicht mehr mit ps, aber jetzt ist das Skript für jeden lesbar ;) Wenn dann eher chmod 700 /usr/bin/wgetter.sh.

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rendegast » 06.10.2009 17:57:20

'man wget' :
-i file
--input-file=file
Read URLs from file. If - is specified as file, URLs are read from the standard input. (Use ./- to read from a file literally named -.)

If this function is used, no URLs need be present on the command line. If there are URLs both on the command line and in an input file, those on the command lines will be the first ones to be retrieved. The file need not be an HTML document (but no harm if it is)---it is enough if the URLs are just listed sequentially.
Diese Dateien dann mit Recht 0700 im home-Verzeichnis, für jede URL eine.
Die Aufgabenstellung verändert sich dann dahingehend:

Code: Alles auswählen

wget  BLAPAGE
zu ->

Code: Alles auswählen

wget  -i /home/$USER/BLAPAGES/BLAPAGE.file

Das größere Problem scheint mir aber die Übertragung per http im Internet
(Setze den Rechner wegen linux einfach mal als (noch) nicht korrumpiert voraus ;) ),
daher:
http://.....
zu ->
https://.....



------------------------------------
wget bietet die Möglichkeit, Passworte über eine ~/.wgetrc zu übergeben,
um das Auftauchen in einer URL zu vermeiden
(auch wenn das hier nicht passt):
http_passwd = STRING
Set HTTP password.
...
passwd = STRING
Set your FTP password to PASSWORD. Without this setting, the
password defaults to `username@hostname.domainname'.
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 06.10.2009 21:40:25

ein wenig verwirrend!

also erstelle ich im home verz. unter /home/ordner/ für jeden crontab eine .sh. sprich:
cron1.sh:

Code: Alles auswählen

#!/bin/sh
THIS="$1"

wget --tries=2 --timeout=2 --wait=2 [--quiet|--no-verbose] -O/dev/null http://domain.tld/buli/extern/[b]cron1[/b].php?pw=cronpw
cron2.sh:

Code: Alles auswählen

#!/bin/sh
THIS="$1"

wget --tries=2 --timeout=2 --wait=2 [--quiet|--no-verbose] -O/dev/null http://domain.tld/buli/extern/[b]cron2[/b].php?pw=cronpw
mit den rechten chmod 0700!

dann mit crontab -e die crontabs auflisten:

Code: Alles auswählen

* * * * 1,4 /home/ordner/cron1.sh
* * * * 1,4 /home/ordner/cron2.sh
usw.

wäre das so korrekt?

uname
Beiträge: 12508
Registriert: 03.06.2008 09:33:02

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von uname » 07.10.2009 08:19:53

Code: Alles auswählen

/home/ordner/cron1.sh
... wenn der Benutzer "ordner" heißt?Eher

Code: Alles auswählen

/root/cron1.sh
Kannst du noch mal erzählen was du ursprünglich erreichen wolltest. Erscheint mir alles etwas komisch.

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rendegast » 07.10.2009 08:43:47

Das war der Ausgang:
(Die Zeiten "normiert", der Übersichtlichkeit halber)
Was sich ändert, sind die Namen der abgerufenen Seiten:
reminder
terminplan
results
liveresults
Der Rest ist "Füllstoff", unelegant.

geändert zu:

Code: Alles auswählen

* * * * * /home/DeinUser/scripts/WGETTER.sh reminder
* * * * * /home/DeinUser/scripts/WGETTER.sh terminplan
* * * * * /home/DeinUser/scripts/WGETTER.sh results
* * * * * /home/DeinUser/scripts/WGETTER.sh results
* * * * * /home/DeinUser/scripts/WGETTER.sh results
* * * * * /home/DeinUser/scripts/WGETTER.sh liveresults
* * * * * /home/DeinUser/scripts/WGETTER.sh liveresults
* * * * * /home/DeinUser/scripts/WGETTER.sh liveresults

(1. Version)
/home/DeinUser/scripts/WGETTER.sh :

Code: Alles auswählen

#!/bin/sh
THIS="$1"
wget -O/dev/null "http://domain.tld/buli/extern/${THIS}.php?pw=cronpw"
(2. Version, mit timeout-Optionen)
/home/DeinUser/scripts/WGETTER.sh :

Code: Alles auswählen

#!/bin/sh
OPTIONS="--tries=2 --timeout=2 --wait=2 --no-verbose"
THIS="$1"
/usr/bin/wget  "$OPTIONS" -O/dev/null "http://domain.tld/buli/extern/${THIS}.php?pw=cronpw"
(3. Version, mit URL-files)
/home/DeinUser/scripts/WGETTER.sh :

Code: Alles auswählen

#!/bin/sh
OPTIONS="--tries=2 --timeout=2 --wait=2 --no-verbose"
THIS="$1"
/usr/bin/wget  "$OPTIONS" -O/dev/null -i /home/DeinUser/scripts/${THIS}.urlfile
mit
/home/DeinUser/scripts/reminder.urlfile (mit https !):

Code: Alles auswählen

https://domain.tld/buli/extern/reminder.php?pw=cronpw
(Analog für 'terminplan', 'results', 'liveresults')
Mit https ist pw=cronpw vor dem Internet geschützt, und mit den *.urlfile vor der Sichtbarkeit in der Prozeßliste.
Und wget-Optionen lassen sich an einer Stelle, in WGETTER.sh, ändern.

Da die Seiten an zwei Tagen minütlich abgerufen werden, sollte der Job nicht überlastet werden,
damit die Verarbeitung sich nicht überschneidet.
Dagegen kann aber auch mit Tests in WGETTER.sh, zBsp. Lockfiles, oder Einstellungen von cron (?) angegangen werden.
Zuletzt geändert von rendegast am 07.10.2009 08:56:48, insgesamt 1-mal geändert.
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

uname
Beiträge: 12508
Registriert: 03.06.2008 09:33:02

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von uname » 07.10.2009 08:54:05

Ich glaube ich habe es dann verstanden. Im übrigen falls du kein offizielles SSL-Zertifikat hast musst du bei wget noch den Parameter:

Code: Alles auswählen

--no-check-certificate
hinzufügen.

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 07.10.2009 19:24:50

so jungs :)

alles super glaube ich. hab mich für version 2 entschieden und denke, dass es funktioniert!

allerdings habe ich nocht eine frage:

Code: Alles auswählen

20 19 * * 3 /home/scripts/wgetter.sh reminder
diesem eintrag nach müsste doch cron den reminder um 19:20 jeden mittwoch ausführen oder?

meine kompletter crontab eintrag ( crontab -e -u username ) schaut so aus:

Code: Alles auswählen

20 19 * * 3 /home/scripts/wgetter.sh reminder
15-45/5 11,15,16,18,20 * * 1,4 /home/scripts/wgetter.sh terminplan
15-45/5 22 * * 5 /home/scripts/wgetter.sh results
15-45/5 17,20 * * 6 /home/scripts/wgetter.sh results
5,10,55 17,18,19 * * 7 /home/scripts/wgetter.sh results
15-45/5 20,21,22 * * 5 /home/scripts/wgetter.sh liveresults
15-45/5 15,16,17,18,19,20 * * 6  /home/scripts/wgetter.sh liveresults
15-45/5 15,16,17,18,19 * * 7 /home/scripts/wgetter.sh liveresults
sagt mir doch wenn es noch fehler in hinsicht der zeit/datum etc. einstellung gibt.

gruß

rac3r
Beiträge: 13
Registriert: 05.10.2009 17:28:11

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rac3r » 07.10.2009 22:59:15

musste leider gerade feststellen, dass der fehler immer noch besteht!

es haben sich wieder über zwanzig /USR/SBIN/CRON Prozesse angesammelt!!!

ich verzweifel...

Code: Alles auswählen

root      3148  0.0  0.1  52076  2092 ?        S    22:27   0:00 /USR/SBIN/CRON
root      3273  0.0  0.1  49972  2060 ?        S    22:30   0:00 /USR/SBIN/CRON
root      3318  0.0  0.1  52112  2064 ?        S    22:31   0:00 /USR/SBIN/CRON
root      3407  0.0  0.1  52112  2064 ?        S    22:33   0:00 /USR/SBIN/CRON
root      3628  0.0  0.1  49972  2060 ?        S    22:39   0:00 /USR/SBIN/CRON
root      4191  0.0  0.1  49972  2060 ?        S    22:53   0:00 /USR/SBIN/CRON

Benutzeravatar
armin
Beiträge: 2682
Registriert: 17.03.2005 11:49:14

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von armin » 07.10.2009 23:28:42

Was passiert eigentlich, wenn du dein Skript von Hand ausführst. Beendet es sich (immer)?
Formerly known as Trigger.
HP 8510p - Debian Sid
Mitglied des Debian-KDE-Teams

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: zuviele Prozesse /USR/SBIN/CRON

Beitrag von rendegast » 08.10.2009 11:32:18

von rac3r am 07.10.2009 22:59:15 GMT
also Mittwoch.
Läuft das Script denn durch?
Wie lange braucht es im Normalfall?
(gegebenenfalls mal ohne das '--no-verbose' oder mit '--verbose' -> Meldungen)

Code: Alles auswählen

sh
time /home/scripts/wgetter.sh terminplan
Meldungen über die Ausführungen im syslog?
Meldungen auf dem Server?


Noch ein 'exit' anhängen?

Code: Alles auswählen

#!/bin/sh
OPTIONS="--tries=2 --timeout=2 --wait=2 --no-verbose"
THIS="$1"
/usr/bin/wget  "$OPTIONS" -O/dev/null "http://domain.tld/buli/extern/${THIS}.php?pw=cronpw"

exit
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

Antworten