So this is a super weird issue. I have a python script that calls many bash commands via subprocess.call based on certain criteria. Now, the script runs just fine manually but when thrown into a cronjob it fails, BUT only when it gets to a certain part of the code. This part of the code runs a bstat
and a bkill
command on a user. I've tried using subprocess.call, subprocess.Popen, subprocess.check_output for these two commands and every time it reaches them, it hangs and does nothing. I then get this message in var/spool/mail/root
File "/root/Desktop/script.py", line 75, in <module>
print subprocess.check_output(['bstat' '-q' 'viz' '-u' ,user,])
File "/usr/lib64/python2.7/subprocess.py", line 568, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I've tried: using absolute paths for EVERY command possible, changing directories to the directory of the script before running, calling /bin/python before running. I'm at a total loss. What's even more weird, is there are other subprocess.call commands that work just fine when calling a bash script but when it comes to those two commands it doesn't know what to do. Below is the first subprocess command that it hangs on:
print subprocess.check_output(['bstat' '-q' 'viz' '-u' ,user,])