Answer the question
In order to leave comments, you need to log in
How to repeat a loop in bash?
Good afternoon!
Tell me, please, what to read and how can it be implemented and is it possible to do this in bash?
You need to constantly check the variables, if the variables are equal to
$1 = $2 ,
then execute the command I need and continue comparing the variables.
If they are equal, then continue comparing them and do nothing until they are not equal,
if they are not equal to
$1 != $2
Then repeat everything from the beginning
Answer the question
In order to leave comments, you need to log in
Based on the comments, something like this
#!/bin/bash
flag=0
while true; do
date=`date |awk'{print $3, $4}'|sed's/.\{3\}$//'`
file=`date -r /var/log/nginx/access.log |awk'{print $3, $4}'|sed's/.\{3\}$//'`
if [ "$date"="$file" ];
then
if [ "$flag"="0" ];
then
flag=1
command_name
echo "Сервис перезапущен"
fi
else
flag=0
echo "Сервис не перезапущен"
fi
done
It is necessary to clarify the condition when exactly and how the variables change
You need to constantly check the variables, if the variables are equal to
$1 = $2 ,
then execute the command I need and continue comparing the variables.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question