Making a Script Behave Like a Daemon

In this chapter, we will introduce the following topics:

  • Running a program continuously (forever) using looping constructs or recursion
  • Keeping programs/scripts running after logoff
  • Invoking commands when they require permissions
  • Sanitizing user input and for repeatable results
  • Making a simple multi-level user menu using select
  • Generating and trapping signals for cleanup
  • Using temporary files and lock files in your program
  • Leveraging timeout when waiting for command completion
  • Creating a file-in-file-out program and running processes in parallel
  • Executing your script on startup

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.