How to limit process running time in Linux
timeout can be used to run a command with a time limit .
timeout [OPTION] DURATION COMMAND
For example, below command will limit
ssh command running time as 10 seconds.
j@ubuntu2004:~$ timeout 10 ssh linuxtutorials.org firstname.lastname@example.org's password: timeout: sending signal TERM to command ‘ssh’
This command is useful when we send a remote command , like we invoke
ssh in script but sometimes it will be hung due to something, by using
timeout we can kill it automatically.
‘s’ for seconds (the default) ‘m’ for minutes ‘h’ for hours ‘d’ for days