Bash History With Timestamps

If you need to see Bash history with timestamps, use this command.

HISTTIMEFORMAT="%d/%m/%y %T "

To make it permanent, add it to your .bashrc.

echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
source ~/.bashrc

Timestamps accuracy is retroactively, meaning it will not be accurate for commands performed prior to the history time format being set.

Tar Commands

Here are two important tar commands on how to create and extract a tar.gz file.

Create a tar gzip file called “project.tar.gz” of a directory called “foo.”

tar -cvzf project.tar.gz foo

Untar the “project.tar.gz” file to a directory called bar.

tar -zxvf project.tar.gz bar

FFMPEG with Start Time

This is a follow up to a previous post about FFMPEG. In addition to sending a RTMP stream, you can also set a start time and duration.

Here’s how to set the start time using -ss option and -to for the duration. Video will start at 1 min 23 secs and play until 2 mins.

ffmpeg -ss 00:01:23 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4

Here’s how to start time to start the video at 1 min 23 sec for RTMP streaming. Please note, the start time option needs to be before the input file.

ffmpeg -ss 00:01:23 \
-re -i $1 -acodec libmp3lame -ar 44100 -b:a 128k \
-pix_fmt yuv420p -profile:v baseline -s 1280x720 -bufsize 6000k \
-vb 1200k -maxrate 1500k -deinterlace -vcodec libx264           \
-preset veryfast -g 30 -r 30 -f flv                            \
-flvflags no_duration_filesize                                 \
"rtmp://username:password@yourserver:1935/live/backup"