I want to enforce timeout of 5s to python command and at the same time want to measure the execution time for python command (taking into account that python3 command memory limit is 256 MB), what I am doing is
ulimit -v 256000 && /usr/bin/time -f \"TIME: %e\" timeout 5s python3 test.py 2>&1
Above command is setting the virtual memory to 256 MB so that python3 command don't exceed above 256 MB, also I am measuring the time using /usr/bin/time and setting the timeout to 5s for python3 command.
I am in doubt that timeout is enforced on python3 command but the time command is put upon timeout as well as python3 command. But I want to set time only only python3 command. As above command will give time for timeout and python3 command execution but I want execution time for python3 command only.
Note: I want all of these actions to occur in a single line, as that is my requirement.
If there are any commands available that can accomplish the above tasks, that would also be acceptable.
timeout 5s /usr/bin/time -f \"TIME: %e\" python3 test.py? b) execution time oftimeoutcommand would be very small.