Answer the question
In order to leave comments, you need to log in
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
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
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.
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 questionAsk a Question
731 491 924 answers to any question