The error is because &
is being passed to the /bin/sleep
command as an argument, whereas you are using it in the context of telling the shell to execute the command in the background.
If you want to use '&' or '&&' you can use os.system
:
os.system('sleep 1 && echo foo && sleep 5 && echo bar')
or to run nonblocking (in the background) you can use the standard &
:
os.system('sleep 1 && echo foo && sleep 5 && echo bar &')