Linux DevOps

Rsync to Android

Connecting Android to your Linux you need to use gvfs. Rsync also wants to set files timestams that is why you need this hack.

 

0. Install gvfs-fuse

For use MTP devices in terminal need to use gvfs-use:

apt install gvfs-fuse

and reboot.

 

1. Find MTP device in /run/user/1000/gvfs

ls /run/user/1000/gvfs
'mtp:host=Samsung_A7_caf675d6'

Next follow to that folder you need to store your data.

 

Bash: Count Minutes and Seconds since Start of a Process

Starting long process you may want to watch how much time is it going. This helps you to guess how much time remains.

Usually you run some process and then watch on it in another terminal window in a loop `while [ 1 ]`.

For example, need to count minutes since the process start. Algorithm and simple bash script are here.

 

1. Store the start time in seconds in a variable

start=$(date +%s)

This stores start point as POSIX time in seconds like: 1660042758

 

Add Date and Time to Each Line in ffmpeg Log with awk

When transcode video or catch bugs in live stream, sometimes it is necessary to log ffmpeg messages with also date and time. This is possible with awk.

 

Insert date and time to ffmpeg log messages using awk

Here we use test stream link from [3]. We run ffplay for check its work:

ffplay https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8 2>&1 | awk 'NF {print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush()}'

Explanation:

System Monitoring Using Telegram Bot

Having systems that need a monitoring or alert about errors and fails you may use Telegram Bot. Next examples of using Telegram Bot help to watch the status of a long process, also to send lines from log, and even more, it is possible to send printscreens or also convert printscreens to text and then send it to your chat in Telegram.

This way you can monitor any process in your system with smartphone in any place.