O
O
OKNOZA2016-03-08 13:23:57
linux
OKNOZA, 2016-03-08 13:23:57

How to make bash execute a command after a certain amount of time?

I sketched out such a script, FFmpeg takes screenshots of TV channels, but how to make it do it every time after 3 minutes and delete the old screenshot?

#!/bin/bash 
ffmpeg -i http://127.0.0.1:1400 -r 0.1 -vframes 1 -s 640x360 -y /var/www/my/2x2.png&
ffmpeg -i http://127.0.0.1:1401 -r 0.1 -vframes 1 -s 640x360 -y /var/www/my/tnt4.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Slava Kryvel, 2016-03-08
@kryvel

add it to the cron
crontab -e
and add it to the beginning of the script

rm -f /var/www/my/2x2.png  /var/www/my/tnt4.png >/dev/null 2>&1

D
Dmitry, 2016-03-08
@plin2s

First, add to the script the deletion of files before creation, in order to fulfill the last condition.
Secondly:
1. in cron schedule for every three minutes
2. at the end of the script "sleep 180" And all this in an endless loop. Well, run - ka your heart desires.

Y
Yuri Chudnovsky, 2016-03-09
@Frankenstine

If At a certain time, then man at or through crontab.
If AFTER a certain time, then sleep for the required number of seconds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question