I'm using a resource-intensive program in a Perl script [specifically rclone to transfer files to Google Drive].
I have yet to figure out how I want to call rclone, as I need to limit the number of instances of rclone based on some condition (anything relevant to preventing server overload, freezing, crashing, etc.). I would like for the script to wait for the apt system "conditions" (this can be for some long or indefinite amount of time) before it executes rclone.
Some details:
- The script itself is essentially passed a file or directory path containing (possibly numerous) files by another program (this program written in Python--call this program
<A>for reference). <A>only returns a value to a script and thus knows nothing about the script orrclone, other than that it accepts input.<A>cannot be altered (i.e. changing<A>is beyond my ken)<A>fires at varying intervals [i.e. sometimes it will execute the script many times rapidly in succession (creating multiple instances), other times it might only fire once every few hours, minutes, etc.]- Assume that
rclonecan't be altered directly either (i.e. again, beyond my ken). - If absolutely necessary, the number of instances of the script can be limited instead of
rclone(though I'd prefer it only berclone, as the processing done by the script is rather light and needs no limitation). - Modules are fine to use.
- I would like to avoid using Unix-like operating system commands like
pgrepandps(unless absolutely necessary).
Currently, I'm using a rather poorly written bash script in place of the Perl script. The bash script implements a rudimentary (poorly designed) "check/sleep loop" using pgrep -wc, sleep, while loops and if statements. (To be honest, I don't even think the bash script really works/helps atm.)