Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Bash snippet - Run a command, see & log its output and execution time.
SUBMITTED BY:
DanielK
DATE:
Aug. 13, 2016, 3:08 p.m.
FORMAT:
Bash
SIZE:
343 Bytes
Raw
Download
Tweet
HITS:
792
Go to comments
Report
function
runl
()
{
if
[
$#
-gt
1
]
;
then
CMDLINE
=
${
@:
1
:
$#
-1
}
;
DATE
=
$(
date
'+%T %B %d %Y'
)
;
LOGFILE
=
${
@:(-1)
}
;
(
echo
-e
'DATE: '
${
DATE
}
'\n''CMDLINE: '
${
CMDLINE
}
'\n'
|
tee
"
${
LOGFILE
}
"
(
eval
time
"
${
CMDLINE
}
"
)
|&
tee
-a
"
${
LOGFILE
}
"
&&
exit
$PIPESTATUS
)
else
echo
"
${
FUNCNAME
}
<command> <logfile>"
fi
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus