The commands you execute on the command line and their outputs are very helpful to debug problems. You might even want to record your sessions as part of an audit policy.
Linux and Unix systems make it very easy using the script command:
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]
DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an
assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.
Options:
-a Append the output to file or typescript, retaining the prior contents.
-c COMMAND
Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its std-
out is not a tty.
-f Flush output after each write. This is nice for telecooperation: One person does âmkfifo foo; script -f fooâ and another can supervise real-time what is
being done using âcat fooâ.
-q Be quiet.
-t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previ-
ous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing
and output delays.
Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts
Saturday, September 22, 2007
Tuesday, July 31, 2007
Need to schedule a job for the last day of the month?
Lets say you need to run a command on the last day of the month. The corn system needs you to provide the day of the month ( like 28,29,30,31) . Since the last day of the month is not a fixed date, cron comes short on this requirement.
Fortunately, these is a easy way to work around this. Shell to the rescue :
00 09 * * * [ `date -d tomorrow +'%d'` = '01' ]&&/command/to/run
Fortunately, these is a easy way to work around this. Shell to the rescue :
00 09 * * * [ `date -d tomorrow +'%d'` = '01' ]&&/command/to/run
Subscribe to:
Posts (Atom)
About Me
- Nikh Nath
- California, United States