Wednesday, September 6, 2023

detect file change in bash redhat

#!/bin/sh

old=$(tail -l $1)

while true
do
  sleep $2
  new=$(tail -l $1)
  if [ "$old" != "$new" ]
  then
     echo "file changed"
     old=$new
  else
     echo "file not changed"
  fi
done

--------------------------- this is to remove all the \r character from the file ---------------------

sed -i 's/\r$//' loop.sh

 --------------------------- run jboss eap service ------------------

[root@dcyfolywb30052 ~]# systemctl daemon-reload

[root@dcyfolywb30052 ~]# systemctl stop jboss-eap-rhel

[root@dcyfolywb30052 ~]# systemctl start jboss-eap-rhel

 

 

No comments:

Post a Comment