Today added a bit of script, feel very useful, happy ~
First clarify the characteristics of Linux/unix:
In general, each unix/Linux command will open three files when it runs: standard input file (stdin): stdin file descriptor for 0,unix program reads data from stdin by default. Standard output file (stdout): StdOut file descriptor for 1,unix program outputs data to stdout by default. standard error file (stderr): The stderr file descriptor for the 2,unix program writes an error message to the stderr stream.
Sometimes, the program just start will brush the log to STD out (console), very annoying ~ today according to the above instructions, optimized the script.
Startup scripts
# !/bin/bashjava-xmx512m-xms64m-xx:permsize=256m-xx:maxpermsize=512m-jar jetty-runner.jar--port 12345 Server-0.0.1-snapshot.war >/web/program/gw/logs/stdout.log 2>&1 &$! >/program.pid
Startup script Description:
1. Java-jar and some JVM parameters
2. Jetty-runner.jar parameters
3. directing standard output, standard error (1/2) from to/web/program/gw/logs/stdout.log
4. & Background Launch
5. Output the PID of the program to Program.pid
Close Script
# !/bin/bash - F ./program.pidrm. /program.pid
Closing the script is simply a pkill-f and then deleting the file.
Small experience
Java-xmx512m-xms64m-xx:permsize=256m-xx:maxpermsize=512m-jar Jetty-runner.jar--port 12345 Server-0.0.1-snapshot.war >/web/program/gw/logs/stdout.log 2>&1 &
Previously there was no red part of the above. The problem is that after the system starts, the console is brushing the logs and God is bored. Add the red above, meaning that the standard output and standard error are output to this file.
Script to run the program with Jetty-runner.jar