daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <SOMETHING ELSE AT START OF SCRIPT>
  2.  
  3. cmd='while true;
  4. do
  5.     ps aux | head;
  6.     sleep 1;
  7. done > $FILE'    
  8.  
  9. ssh root@$SERVER $cmd &
  10. ...
  11. ...
  12. <SOME OTHER TASKS>
  13. ...
  14. ...
  15. ( at the end of this script, how to kill the above snippet executing in remote server)
  16. [ kindly note i dont want to wait as the while loop is infinite ]
  17.    
  18. cmd='while [ -r /tmp/somefile];
  19. do
  20.   # stuff
  21. done > $FILE'
  22.  
  23. ssh root@$SERVER touch /tmp/somefile
  24. ssh root@$SERVER $cmd &
  25. # do other stuff
  26. ssh root@$SERVER rm -f /tmp/somefile
  27.    
  28. kill $!
  29.    
  30. CTRL+Z
  31. fg
  32. CTRL+C
  33.    
  34. jobs
  35. kill %jobspec
  36.    
  37. whois=`w|grep $user|awk '{print $2}'`;user=root; ssh $user@server -C "ps auwx|grep $whois|awk '{print $2}'"
  38.    
  39. whois=`w|grep $user|awk '{print $2}'`;user=root; ssh $user@server -C "ps auwx|grep $whois|awk '{print $2}'|xargs kill -9  "
  40.  
  41.  
  42.  whois=`w|grep $user|awk '{print $2}'`;user=root; ssh $user@server -C "ps auwx|grep $whois|awk '{print $2}'|awk '{print "kill -9 " $1}'|/bin/sh "
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top