I'm running a python script where I'm using subprocess to call serious of rclone copy operations. Since rclone isn't a native command, I'm defining it from a shell script run automatically by my .bashrc file. I can confirm that works since subprocess.run("rclone") properly pulls the rclone menu.
The issue is when I run my script, I don't get any errors or exceptions. Instead my terminal window shows the following:
I understand the issue is related to the Linux subprocess being backgrounded. However, this solution didn't seem to fix my issue, and I can't find anything about how to prevent this process from pausing. I can confirm it is distro independent as I have run on RedHat and on Amazon EC2.
Last key piece of info: I am calling the subprocess as bash rather than sh to load the alias via my bashrc file. Here is the minimum reproducible code:
start_date = datetime.strptime(datetime.now(timezone.utc).strftime("%Y%m%d"), "%Y%m%d")
# For good measure, double check the day before for more files if the date just changed
time = datetime.utcnow().strftime("%H")
if int(time) <= 3:
start_date = start_date - timedelta(days = 1)
end_date = start_date + timedelta(days = 2)
else:
# End tomorrow
end_date = start_date + timedelta(days = 1)
# Force python to use the bash shell
def bash_command(cmd):
subprocess.Popen(['/bin/bash', '-i', '-c', cmd])
for dt in daterange(start_date, end_date):
cmd = 'rclone copy "/home/test.png" "AWS test:"'
bash_command(cmd)