Synchronize a script with another software in linux
I want a script starts to run in background automatically each time google-chrome started and automatically turn off itself whenever google-chrome closed. Is there a simple way to do it under linux? I would like to see some details about how it can be done. Thank you for the answers.
|
Quote:
Code:
#!/bin/bash |
Quote:
Code:
#!/bin/bash Code:
#!/bin/bash Code:
top -b -n 1 | grep chrome If I do Code:
#!/bin/bash I also tried add one line at bottom of /usr/bin/google-chrome to run Chrome_Backup. Then I run google-chrome from terminal, the chrome still work but inotifywait can not be invoked. The code of my script should be fine, since it works if I run it and chrome separately. I do not know why it dose not work if I run both in one script. Any one has any idea? |
Following the same idea of my backup script, if I want to write another backup script for Latex. That is, whenever I finish my writing and turn-off my texmaker editor, the script automatically send a copy of the latest saved .tex, .aux, .bib files to my Dropbox directory. How can I achieve this?
I do not want to work directly in my Dropbox directory, because that will mess up my other things and I also want to make backup copies to several other cloud servers, not only Dropbox. |
Quote:
I would swap the order, so chrome is run first, and stick a "&" on the end to fork it to the background. Then use "$!" to grab the PID of the chrome process, and pass that as an argument to Chrome_Backup. Inside Chrome_Backup you would monitor that PID, and exit when the PID is no longer running. Alternatively, you could fork both processes to the background, then dive into an endless while loop that monitors the chrome PID. When the chrome PID exits, you could force kill the PID of the backup script (or however else you normally exit the backup script). Something like: Code:
#!/bin/bash |
Couldn't you just
Code:
#!/bin/bash |
Yep that would probably work too, and is a bit more graceful than my last reply. I'm not sure how the backup script needs to be killed though, maybe it needs to be "politely" stopped?
|
All times are GMT -5. The time now is 04:09 AM. |