I'm playing the shell game of moving and deleting files to make room for current DB backup. A set of files gets moved to serverB when serverA threshold is exceeded. I created two scripts one for serverA and one for serverB. Both scripts are run by cron entry. There is a difference of 12 minutes between the servers. I'm trying to get that question answer from the senior admin as to why the time difference. ServerA will fire at a predetermine time "sleep xxx" to allow serverB read a file sent from serverA. The file is capacity of filesystem u06. If file exceeds threshold delete files on serverB.
My question is there a better way to run the scripts due to time difference? My thought is to invoke serverB script from serverA script. How can I fire off serverB script from serverA script?
#!/bin/sh
# Your code here
#Here you start the script
ssh $SERVER_NAME script_b.sh
#This should also do the job:
ssh $SERVER_NAME <<EOF
script_b.sh
exit
EOF
#And then rm what you want to rm
This way you will start script B immediately after script_a and when script_b is finished you can delete your files (from script_a).
If I understand you correctly, create another script to run both scripts. That's way too cool! This has been a great week learning new things with scripting. Thanks.
Actually my point was to call script_b from script_a. And the code up there was meant for script_a. But of course there is no problem to create new script to call both of them.