Bash: Terminate on Timeout/File Overflow while Executing Command
问题 I'm writing a mock-grading script in bash. It's supposed to execute a C program which will give some output (which I redirect to a file.) I'm trying to (1) make it timeout after a certain duration and also (2) terminate if the output file reaches a certain file size limit. Not sure how to go about either of these. Any help? Thanks. 回答1: There's a GNU coreutil command timeout to do timeouts. Investigate ulimit -f 32 to set the maximum file size (to 16 KiB; it counts in 512 byte blocks).