1837672 Members
3668 Online
110117 Solutions
New Discussion

ssh

 
SOLVED
Go to solution
Shivkumar
Super Advisor

ssh

Hi,

I want to execute a shell script on remote server from a source server. However, the script should execute on the target machine directory only if the contents in the target directory changes.

How to accomplish this ?

Thanks,
Shiv
3 REPLIES 3
skt_skt
Honored Contributor

Re: ssh

You can look for files with the current date/previous date time stamps(depending on when you want to check; like before 12AM or after 12AM)
skt_skt
Honored Contributor

Re: ssh

ssh -n hostname "command"
James R. Ferguson
Acclaimed Contributor
Solution

Re: ssh

Hi Shiv:

Your script (on the target server) should simply exit if when run the directory it examines hasn't changed since the last time it interrogated it.

To accomplish something like this, you capture the last modification time of the target directory as file metadata. Then when you script runs, compare the modification time of the target directory to the reference file's timestamp.

To storing and comparing file timestamps use:

# touch -mr ref_file target

Compare the reference file and target directory ages with the '-ot' or '-nt' file test operators. See the manpages for 'touch' and for 'sh-posix' for more details.

Regards!

...JRF...