This command will log the output of your simple cronjobs to syslog, and syslog will take it from there. Works great for monitoring scripts which only produce simple output. Advantages: * This can be used by regular users, without modifying system files like /etc/syslog.conf * Reduce cron spam to root@localhost (Please stop spaming the sysadmins) * Uses common tools like syslog (and logrotate) so that you don't need to maintain yet another krufty logfile. * Still ensures that the output is logged somewhere, for posterity. Perhaps it's stored the secure, central syslog server, for example. * Seems to work fine on Ubuntu, CentOS, FreeBSD & MacOSX Show Sample Output
When debugging an ssh connection either to optimize your settings ie compression, ciphers, or more commonly for debugging an issue connecting, this alias comes in real handy as it's not easy to remember the '-o LogLevel=DEBUG3' argument, which adds a boost of debugging info not available with -vvv alone. Especially useful are the FD info, and the setup negotiation to create a cleaner, faster connection. Show Sample Output
This will show all changes in all log files under /var/log/ that are regular files and don't end with `gz` nor with a number Show Sample Output
A wrapper around ssh to automatically provide logging and session handling.
This function runs ssh, which runs screen, which runs script.
.
The logs and the screen session are stored on the server.
This means you can leave a session running and re-attach to it later, or from another machine.
.
.
Requirements:
* Log sessions on a remote server
* Transparent - nothing extra to type
* No installation - nothing to copy to the server beforehand
.
Features:
* Function wrapper delegating to ssh
- so nothing to remember
- uses .ssh/config as expected
- passes your command line option to ssh
* Self-contained: no scripts to install on the server
* Uses screen(1), so is:
- detachable
- re-attachable
- shareable
* Records session using script(1)
* Configurable log file location, which may contain variables or whitespace
L="$HOME" # local variable
L="\$HOME" # server variable
L="some space"
.
Limitations:
* Log dir/file may not contain '~' (which would require eval on the server)
.
.
The sessions are named by the local user connecting to the server.
Therefore if you detach and re-run the same command you will reconnect to your original session.
If you want to connect/share another's session simply run:
USER=bob ssh root@server
.
The command above is stripped down to an absolute minimum.
A fully expanded and annotated version is available as a Gist (git pastebin):
https://gist.github.com/flatcap/3c42326abeb1197ee714
.
If you want to add timing info to script, change the command to:
ssh(){ L="\$HOME/logs/$(date +%F_%H:%M)-$USER";/usr/bin/ssh -t "$@" "mkdir -p \"${L%/*}\";screen -xRRS $USER script --timing=\"$L-timing\" -f \"$L\"";}
Show Sample Output
You could also pipe to logger.
This is similar to standard `pv`, but it retains the rate history instead of only showing the current rate. This is useful for spotting changes. To do this, -f is used to force pv to output, and stderr is redirected to stdout so that `tr` can swap the carriage returns for new lines. (doesn't work correctly is in zsh for some reason. Tail's output isn't redirected to /dev/null like it is in bash. anyone know why? ???????) Show Sample Output
GoAccess is an open source real-time Apache web log analyzer and interactive viewer that runs in a terminal in *nix systems. It provides fast and valuable HTTP statistics for system administrators that require a visual server report on the fly. http://goaccess.prosoftcorp.com/ Show Sample Output
Put this logging function in you're script, when need it call it. command || logme "Error with command"
This bash one-liner will let you watch the tail end of a log file in real time.
IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type
powershell
Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds.
Any changes in the host's Up/Down state is time-stamped and logged to a file.
Date/time stamps are logged in two formats: Unix and human-readable.
A while(1) loop repeats the test every 10 seconds by using the sleep command.
See the Sample Output for more detail.
I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1).
To end the logging, close the PowerShell window or use the "exit" command.
Show Sample Output
Run a job in the background and prefix it's output with some string. This is particularly useful if you are running inside a docker container in a startup script (sue me, I'll run two jobs in a docker container if I want to) and you can run something like: /usr/sbin/nginx 2>&1 | awk '{print "[NGINX] " $0}' & /opt/jws-3.1/tomcat8/bin/catalina.sh run 2>&1 | awk '{print "[TOMCAT] " $0}' & while true; do ; done it can also be combined with tee to create a file log as well as a stdout log, for example if the script above where a script called "/bin/start-container.sh" then you could run /bin/start-container.sh | tee /var/log/containerlogs Show Sample Output
Tail all logs that are opened by all java processes. This is helpful when you are on a new environment and you do not know where the logs are located. Instead of java you can put any process name. This command does work only for Linux.
The list of all log files opened by java process:
sudo ls -l $(eval echo "/proc/{$(echo $(pgrep java)|sed 's/ /,/')}/fd/")|grep log|sed 's/[^/]* //g'
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: