Posts: 1,033
Threads: 85
Joined: Oct 2013
Does something like this actually work?
./server.sh 2>&1 |tee -a servername/severname_`date +"%Y-%m-%d`.log
Actually work or will it not update the date command every day?
Posts: 447
Threads: 9
Joined: May 2012
08 Mar 14, 09:08AM
(This post was last modified: 08 Mar 14, 09:11AM by blueberry.)
It won't create more than one file so you'll only get the date when the tee command is executed.
Also, see here.
Posts: 1,039
Threads: 77
Joined: Jun 2010
08 Mar 14, 09:45AM
(This post was last modified: 10 Mar 14, 09:36AM by RandumKiwi.)
Blueberry is correct. It won't create more than one file, so you'll only get the date when the tee command is executed. I know from experience there's a way around this (and it's not the way you probably think it is - because that way, breaks the logging), but I'm not going to explain this method to you.
Why?
Using the actual Linux logging system, would work better, as it has better redundancy built in (i.e. less chance of missing something, etc). Additionally, 'tee' will only append to a file every now-and-then, not straight away
So, I'll be helpful and give you some instructions to do what you want, for an rsyslog based system!
Step 1: You'll notice that everything from AssaultCube is already being logged to /var/log/syslog - so, no need to set up logging, just re-configure it to direct correctly.
Step 2: Open /etc/rsyslog.conf and find this line to change:
*.*;auth,authpriv.none -/var/log/syslog
Replace it with the following, which will stop AssaultCube from being logged to /var/log/syslog:
*.*;auth,authpriv.none;local6.none; -/var/log/syslog
Step 3: I recommend that above where the "RULES" list is, that you use the following extra commands:
$ActionResumeRetryCount -1 # Infinite retries on insert-failure.
$ActionQueueType LinkedList # Memory-based logging, this one uses less memory/more CPU.
$ActionQueueFileName /var/log/emergency_rsyslog # Enables disk-assist, just in case of failure.
$ActionQueueMaxFileSize 250M # Limit emergency file-size, just in case.
$ActionQueueSaveOnShutdown on # Save in-memory data if rsyslog shuts down.
Step 4: Below the commands you just copy/pasted, type this to redirect the log to a file, on a per-server basis. Ensure you replace "SERVERTAG" with whatever your server tag is. Remember, you can change this tag using the -N command-line argument:
if $syslogtag contains 'SERVERTAG' then /path/to/your/logfile.log
Step 4 OPTIONAL: Use the following to just redirect ALL AssaultCube log data to a file:
if $programname == 'AssaultCube' then /path/to/your/logfile.log
Step 5: Below these, add the following line to stop any further data being logged to syslog:
Step 6: After all these changes, save the file. Reboot rsyslog:
Congratulations. You're now logging AssaultCube to a separate file (or files if you did it on a per-server basis) and not clogging your syslog file! Now we talk about logrotate. You should use logrotate (instead of your own script) - but, if you've come this far and don't trust me, I'm not going to explain why you should - go google it.
The following syslog commands will make your files be archived by date in the folder they were found.
Step 7: In this example, I'm going to pretend the config file is named /etc/logassaultcube.conf (replace the filepath in all the examples below if you choose a different name).
nano -w /etc/logassaultcube.conf
Step 8: Copy/paste the below code into the file, then adjust it according to your needs. If you're not sure what any of these options do, then type 'man logrotate':
nocompress # Don't tarball any of the logs.
/path/to/your/logfile.log {
rotate 36500 # Keep archived logs for 100 years.
daily # Rotate daily (not weekly, etc).
missingok # Rotate even if file is missing.
ifempty # Rotate even if file is empty.
noolddir # Don't archive logs into a separate folder.
dateext # Archived logs get dated, as per below:
dateformat -%Y-%m-%d # NAME-2014-03-09.log
extension .log # NAME-2014-03-09.log
create 0644 root root # Permissions for archived files.
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
Step 9: Set up a script run your logrotate file. In this example, I'm going to pretend the script file is named /etc/logassaultcube.sh (replace the filepath in all the examples below if you choose a different name).
nano -w /etc/logassaultcube.sh
Step 10: Copy/paste the below into that script file:
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate -f /etc/logassaultcube.conf
Step 11: Make the script file executable:
chmod +x /etc/logassaultcube.sh
Step 12: Set up the super-user's cron to run logrotate at 11:59pm daily:
Step 13: Copy/paste this line into the crontab:
59 23 * * * /etc/logassaultcube.sh
... AND, you're done.
Posts: 1,039
Threads: 77
Joined: Jun 2010
Not even a thank you?
By the way, your logging to a file by date using tee... I REALLY REALLY don't recommend it, but the solution is to set up a once-daily crontab, which copies (not moves) the file somewhere else. Then, to clear the file without interrupting the logging, use 'echo "" > /path/to/file.log'.
Posts: 1,033
Threads: 85
Joined: Oct 2013
Sorry, I haven't had a chance to try your solution yet. I usually give a thank you after I try and it works =P
But thank you for supplying one. =P
Posts: 525
Threads: 10
Joined: Jun 2013
I have been shown a number of ways to set up logging, but not yet seen anyone put forth a clear set of instructions like this with regards to AssaultCube...
You may be random, but you are an awesome kiwi...
Thank you for putting forth the effort to manifest this here!
Posts: 574
Threads: 83
Joined: Jun 2010
I think this thread should be pinned for all others
Posts: 1,033
Threads: 85
Joined: Oct 2013
10 Mar 14, 03:35PM
(This post was last modified: 10 Mar 14, 03:46PM by Mousikos.)
(08 Mar 14, 09:45AM)RandumKiwi Wrote: ...
My /etc/rsyslog.conf looks different (I didn't do default configs). The thing seems to be running some Debian-derivative (Ubuntu?). Are you running systemd? My VPS seems to be....
At any rate I'll try this out, and I'll work this out to work with systemd and get it all working and I'll post a systemd guide.
Posts: 1,039
Threads: 77
Joined: Jun 2010
10 Mar 14, 08:11PM
(This post was last modified: 11 Mar 14, 08:36AM by RandumKiwi.)
(10 Mar 14, 03:35PM)Mousikos Wrote: (08 Mar 14, 09:45AM)RandumKiwi Wrote: ...
My /etc/rsyslog.conf looks different (I didn't do default configs). The thing seems to be running some Debian-derivative (Ubuntu?). Are you running systemd? My VPS seems to be....
At any rate I'll try this out, and I'll work this out to work with systemd and get it all working and I'll post a systemd guide.
Yes, these instructions are for a debian system with rsyslog installed. But, rsyslog is quite generic, it should not be hard to figure it out for a non-debian system.
Posts: 1,033
Threads: 85
Joined: Oct 2013
Okay. So I figured out that I had a stupid way back when. I am not using systemd. However, I think I'm doing something stupidly wrong that I just can't figure out. Help?
Here are a few files I am having trouble with:
rsyslog.conf
http://paste.ubuntu.com/7370792/
/etc/rsyslog.d/20-ufw.conf
http://paste.ubuntu.com/7370797/
/etc/rsyslog.d/50-default.conf
http://paste.ubuntu.com/7370798/
cmdline file:
https://dpaste.de/EO10
Posts: 2,136
Threads: 50
Joined: Jun 2010
Quote:...
#AssaultCube
*.*;auth,authpriv.none;local6.none; -var/log/syslog
...
If you have AC running on local6 (the default facility), specifying local6.none to syslog is simply going to cause AC not to be logged by the system at all. You need to then point local6.* to a file, eg.
# Save AC messages to AC log
local6.* -/usr/games/ac/logs/callisto.txt
Posts: 1,039
Threads: 77
Joined: Jun 2010
01 May 14, 11:11AM
(This post was last modified: 01 May 14, 11:17AM by RandumKiwi.)
(01 May 14, 08:38AM)jamz Wrote: Quote:...
#AssaultCube
*.*;auth,authpriv.none;local6.none; -var/log/syslog
...
If you have AC running on local6 (the default facility), specifying local6.none to syslog is simply going to cause AC not to be logged by the system at all. You need to then point local6.* to a file, eg.
# Save AC messages to AC log
local6.* -/usr/games/ac/logs/callisto.txt
Incorrect, as he's attempted to make AC direct somewhere later (see "if $syslogtag"... rsyslog's different to normal syslogd).
Stab in the dark, from my own testing. I think that it's your AC config... one small whitespace makes a tonne of difference:
-N MCastle = local#28763
-NMCastle = NCastle
Of course, this all depends on how you're issuing these command line options... so, please, run the server, and give me the output of your log that goes like this (or similar):
logging started: console(INFO), file(DISABLED), syslog(INFO, "AssaultCube[MCastle]", local6), timestamp(DISABLED)
Posts: 1,039
Threads: 77
Joined: Jun 2010
Also, another stab in the dark. Put your new AC directives *AFTER* the line that states $IncludeConfig /etc/rsyslog.d/*.conf
(some of them may conflict?)
Posts: 1,033
Threads: 85
Joined: Oct 2013
01 May 14, 03:54PM
(This post was last modified: 01 May 14, 04:00PM by Mousikos.)
(01 May 14, 11:11AM)RandumKiwi Wrote: (01 May 14, 08:38AM)jamz Wrote: Quote:...
#AssaultCube
*.*;auth,authpriv.none;local6.none; -var/log/syslog
...
If you have AC running on local6 (the default facility), specifying local6.none to syslog is simply going to cause AC not to be logged by the system at all. You need to then point local6.* to a file, eg.
# Save AC messages to AC log
local6.* -/usr/games/ac/logs/callisto.txt
Incorrect, as he's attempted to make AC direct somewhere later (see "if $syslogtag"... rsyslog's different to normal syslogd).
Stab in the dark, from my own testing. I think that it's your AC config... one small whitespace makes a tonne of difference:
-N MCastle = local#28763
-NMCastle = NCastle
Of course, this all depends on how you're issuing these command line options... so, please, run the server, and give me the output of your log that goes like this (or similar):
logging started: console(INFO), file(DISABLED), syslog(INFO, "AssaultCube[MCastle]", local6), timestamp(DISABLED) I thought Stef said (on irc) that whitespace doesn't matter anymore?
reading commandline parameters from file 'config/servercmdline.txt'
reading commandline parameters from file 'config/custom/cmdline/CastleCmdLine.txt'
logging started: console(INFO), file(DISABLED), syslog(VERBOSE, "AssaultCube[MCastle]", local6), timestamp(ENABLED)
(01 May 14, 11:14AM)RandumKiwi Wrote: Also, another stab in the dark. Put your new AC directives *AFTER* the line that states $IncludeConfig /etc/rsyslog.d/*.conf
(some of them may conflict?)
No effect. Here's the weird thing, I'm pretty sure castle.log is being created. But 1) I have to sudo vim to view it, 2) The contents contain 0 lines, 0 bytes (unlike where syslog is actually being logged to)
Posts: 2,136
Threads: 50
Joined: Jun 2010
(01 May 14, 11:11AM)RandumKiwi Wrote: ...see "if $syslogtag"... Oh, yes.
(01 May 14, 03:54PM)Mousikos Wrote: I thought Stef said (on irc) that whitespace doesn't matter anymore? It doesn't in servercmdline.txt, but it does if you put the switch in the command line.
Posts: 1,039
Threads: 77
Joined: Jun 2010
02 May 14, 11:01PM
(This post was last modified: 02 May 14, 11:19PM by RandumKiwi.)
(02 May 14, 09:57AM)jamz Wrote: (01 May 14, 03:54PM)Mousikos Wrote: I thought Stef said (on irc) that whitespace doesn't matter anymore? It doesn't in servercmdline.txt, but it does if you put the switch in the command line.
(01 May 14, 11:11AM)RandumKiwi Wrote: Of course, this all depends on how you're issuing these command line options...
... and, as such, it's good to see that AC is definitely logging correctly, based on your output above.
(01 May 14, 03:54PM)Mousikos Wrote: No effect. Here's the weird thing, I'm pretty sure castle.log is being created. But 1) I have to sudo vim to view it, 2) The contents contain 0 lines, 0 bytes (unlike where syslog is actually being logged to)
Note how your cfg has these:
$FileOwner syslog
$FileGroup adm
Are syslog/adm able to write to the directory the logfile is stored in?
P.S: On debian, those settings are root/adm by default.
P.P.S: You've restarted rsyslog service each time, before you tested, right?
P.P.P.S: For testing, please remove &~
P.P.P.P.S: If all else fails, do it like normal syslog, as mentioned by jamz. I've found rsyslog's syntax to be a PITA sometimes (make sure rsyslog is up to date!!!)
Posts: 1,033
Threads: 85
Joined: Oct 2013
(02 May 14, 11:01PM)RandumKiwi Wrote: (02 May 14, 09:57AM)jamz Wrote: (01 May 14, 03:54PM)Mousikos Wrote: I thought Stef said (on irc) that whitespace doesn't matter anymore? It doesn't in servercmdline.txt, but it does if you put the switch in the command line.
(01 May 14, 11:11AM)RandumKiwi Wrote: Of course, this all depends on how you're issuing these command line options...
... and, as such, it's good to see that AC is definitely logging correctly, based on your output above.
(01 May 14, 03:54PM)Mousikos Wrote: No effect. Here's the weird thing, I'm pretty sure castle.log is being created. But 1) I have to sudo vim to view it, 2) The contents contain 0 lines, 0 bytes (unlike where syslog is actually being logged to)
Note how your cfg has these:
$FileOwner syslog
$FileGroup adm
Are syslog/adm able to write to the directory the logfile is stored in?
P.S: On debian, those settings are root/adm by default.
P.P.S: You've restarted rsyslog service each time, before you tested, right?
P.P.P.S: For testing, please remove &~
P.P.P.P.S: If all else fails, do it like normal syslog, as mentioned by jamz. I've found rsyslog's syntax to be a PITA sometimes (make sure rsyslog is up to date!!!)
Sorry I injured my palms today so using my laptop will hurt so I'm taking a break but I have to double check.
PS: Seems to be the same on Ubuntu
PPS: Yes.
PPPS: Tried it.
PPPPS: Updated today just in case. Didn't fix anything.
Posts: 1,039
Threads: 77
Joined: Jun 2010
(03 May 14, 01:48AM)Mousikos Wrote: PS: Seems to be the same on Ubuntu
Line #42 of http://paste.ubuntu.com/7370792/ says otherwise.
|