Link to home
Start Free TrialLog in
Avatar of jwnrb
jwnrb

asked on

Running commands from a remote server

Hi,

I am making a shell script thats going to be a cron job that uploads various data to another server (using scp).

However, i like to also erase those files that are 1 week old.  however, i can think of a way of running a command from my script so it does it on the remote server.

i am sure its simpler than i think.  any suggestions?


this is the command i like to run.
find ~/.backup ­mtime +7 -exec rm -v {} / ;

also i only want to erase those files in the .backup folder.  i dont want it go into any sub-dirs or other trees.  just look in .backup and thats it.

did i construct my find correctly as well?  thanks.
Avatar of jwnrb
jwnrb

ASKER

as whats wrong with this?

rsh foobar -l me find ~/hh532.backup -mtime +7 -exec rm -v {} \;

ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jwnrb

ASKER

i think somehting like this should work then
ssh me@foobar 'find ~/.backup -mtime +7 -exec rm -v {} \;'

i jsut tested it and it seemed to be fine.

i am using debian linux kernel 2.4.18
Yes, the you ssh command line systax is correct.

or you can do:

ssh -l me foobar "find ~/.backup -mtime +7 -exec rm -v {} \;"

Cheers!

Avatar of jwnrb

ASKER

well it was my quotes that was causing the problem look at that!  and you helped my realise rsh is not good and to use ssh (which was my gut instinct, just wasnt sure :-/ )

i was getting errors with -exec so i though the entire find was wrong