Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SOLVED - Umleitung STDOUT in eindeutigen Filenamen?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
andreas2000
Tux's lil' helper
Tux's lil' helper


Joined: 02 Nov 2004
Posts: 144
Location: Austria/Vienna

PostPosted: Thu Jan 13, 2005 3:52 pm    Post subject: SOLVED - Umleitung STDOUT in eindeutigen Filenamen? Reply with quote

Hallo zusammen,

ich sitze hier schon wieder 2 Tage an einer Sache und komme nicht weiter - vielleicht hats aber schon wer von Euch realisiert...

Ich habe einen Cron Job gemacht, den ich dazu bewegen will eindeutige Logfiles zu schreiben.

Der Code sieht zur Zeit so aus:
Code:

30 4 * * *    root    /mysqlimport/oracle2mysql 2>&1 >/var/log/oracle2mysql/log


nun will ich gerne das log File eindeutig benennen. Momentan behelfe ich mir noch unschön damit indem ich es am Ende der Batchdatei einfach mit einem DateTimeStamp versehe und umbenenne, weil alle Versuche das mittels
Code:

$(date +%Y%m%d%H%M%S)

direkt im Cron Job anzupassen leider fehlgeschlagen sind.

Weiß wer von Euch wie sich das realisieren lassen könnte?

Vielen Dank schon mal für Eure Mithilfe und noch einen schönen Tag,

Andreas.
[/quote]
_________________
Registered Linux User 371244


Last edited by andreas2000 on Mon Jan 17, 2005 9:12 am; edited 1 time in total
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Thu Jan 13, 2005 4:25 pm    Post subject: Reply with quote

/bin/date anstelle date verwenden, da der cron die Umgebung und damit Pfade nicht kenn1 ?

Obige Zeile war Quatsch, ich denke, Du kanst im crontab keine 'dynamischen' Befehlszeilen einbauen. Von den nachfolgenden beiden Einträgen funktioniert halt nur der erste :
Code:

$> crontab -l
* * * * * /bin/date > /tmp/test &
* * * * * /bin/date > /tmp/test_`/bin/date +%Y%m%d%H%M%S` &


Last edited by toralf on Thu Jan 13, 2005 4:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
Anarcho
Advocate
Advocate


Joined: 06 Jun 2004
Posts: 2970
Location: Germany

PostPosted: Thu Jan 13, 2005 4:27 pm    Post subject: Reply with quote

Das dürfte daran liegen das cron den befehl nicht im kontext einer bash ausführt und daher keine variablen kennt. Schreibt dir ein script welches dann

befehl >> /var/log/$(date +...) beinhaltet und rufe das per cron auf. wenn in der ersten zeile

#!/bin/bash

steht wird das mit der bash ausgeführt und sollte klappen
_________________
...it's only Rock'n'Roll, but I like it!
Back to top
View user's profile Send private message
Fauli
l33t
l33t


Joined: 24 Apr 2004
Posts: 760
Location: Moers, Germany

PostPosted: Fri Jan 14, 2005 8:10 pm    Post subject: Reply with quote

@andreas2000: Hast du man 5 crontab nicht gelesen? :wink:
Quote:
The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion
of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in
the SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash
(\), will be changed into newline characters, and all data after the first % will be sent to the command
as standard input.
Back to top
View user's profile Send private message
andreas2000
Tux's lil' helper
Tux's lil' helper


Joined: 02 Nov 2004
Posts: 144
Location: Austria/Vienna

PostPosted: Mon Jan 17, 2005 9:16 am    Post subject: Reply with quote

...da sieht mans wieder: wer lesen kann ist klar im Vorteil... vielen Dank für den Hinweis mit der Manpage - das hat geholfen und nun funktionierts:

Code:

* * * * * /mysqlimport/oracle2mysql 2>&1 >/var/log/oracle2mysql/log_$(/bin/date +\%Y\%m\%d\%H\%M\%S)

_________________
Registered Linux User 371244
Back to top
View user's profile Send private message
tam
Guru
Guru


Joined: 04 Mar 2003
Posts: 569

PostPosted: Mon Jan 17, 2005 11:08 am    Post subject: Reply with quote

logrotate ist für solche Sachen auch praktisch
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) 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