Bash – How to set a timeout within a BASH script for a process that sometimes becomes inactive

bashscripting

I have a bash script that runs a lot of commands/tools like convert or pdftk via CRON.

It happens quite often that e.g. pdftk becomes "stale" or "hangs" and the calling script stops proceeding.

Is there a simple way from within the bash script (via trap?) to set a time limit for execution or detect inactivity (by whatever definition) for a specific call?