What is Child Process?
A subprocess spawned by the scheduler or parent process to run a job in isolation.
Definition
A child process is a separate operating system process created by a parent process (typically the scheduler or shell) to execute a job. When cron triggers a job, it forks a child process that runs the command independently. The child inherits environment variables from the parent but runs in its own memory space. If the child crashes, the parent process is unaffected. Child processes report their exit status back to the parent when they complete.
Simple Analogy
Like a manager delegating a task to an employee โ the employee works independently, and if they encounter a problem, the manager is still available to assign the task to someone else.
Why It Matters
Understanding child processes explains why cron jobs sometimes behave differently than commands run manually. The child process may have a different PATH, different environment variables, and a different working directory than your interactive shell. This is the most common source of "it works manually but not in cron" issues.
How to Verify
Use "ps aux" to see running processes and their parent-child relationships. "ps -ef --forest" shows the process tree. Check your cron job logs for environment-related errors. Test your job command in a minimal shell environment to simulate the child process context cron provides.
Common Mistakes
Assuming the child process has the same environment as your interactive shell โ cron provides a minimal environment. Not using full paths to executables in cron jobs because PATH is different. Not handling the child process exit code, missing failures. Leaving orphaned child processes when the parent is killed.
Best Practices
Always use absolute paths in cron job commands. Explicitly set required environment variables in your crontab or script. Handle child process exit codes to detect failures. Set timeouts to prevent runaway child processes from consuming resources indefinitely.
Documentation
Read the full docs
Try it free โFrequently Asked Questions
What is Child Process?
A child process is a separate operating system process created by a parent process (typically the scheduler or shell) to execute a job. When cron triggers a job, it forks a child process that runs the command independently. The child inherits environment variables from the parent but runs in its own memory space. If the child crashes, the parent process is unaffected. Child processes report their exit status back to the parent when they complete.
Why does Child Process matter for cron jobs?
Understanding child processes explains why cron jobs sometimes behave differently than commands run manually. The child process may have a different PATH, different environment variables, and a different working directory than your interactive shell. This is the most common source of "it works manually but not in cron" issues.
What are best practices for Child Process?
Always use absolute paths in cron job commands. Explicitly set required environment variables in your crontab or script. Handle child process exit codes to detect failures. Set timeouts to prevent runaway child processes from consuming resources indefinitely.
Related Terms
Exit Code
A numeric value returned by a process to indicate success (0) or a specific type of failure.
Environment Variables
Key-value configuration pairs passed to a job's execution context by the operating system.
Working Directory
The filesystem path where a job executes and from which relative file paths are resolved.
Process Isolation
Running each job in a separate process or container to prevent interference between jobs.
Cron Daemon
The background process that continuously checks and executes scheduled cron jobs.