Process Management & Scheduling
Scenario: Taming a Rogue Data Processing Script and Scheduling Cleanup
Objective: A data processing script (data_cruncher.sh), started by a user, is consuming excessive CPU and memory. You need to identify it, control its execution, and schedule a nightly script to clean up temporary files it generates.
🔎 Process Identification & Monitoring
- Use top or htop to monitor running processes and identify resource hogs.
- Find the process ID (PID) of data_cruncher.sh for targeted management.
🛑 Controlling & Managing Processes
- Terminate or restart misbehaving processes with kill and kill -9.
- Adjust process priority using nice and renice to prevent resource starvation.
- Use nohup and job control (Ctrl+Z, bg, fg) for robust process management.
⏰ Scheduling & Automation
- Automate cleanup of temporary files with cron (crontab -e, crontab -l).
- Schedule one-time jobs with at and manage them with atq.
- Understand the difference between cron and systemd timer units for recurring tasks.
💡 Pro Tips
- Always check process ownership before sending signals to avoid disrupting other users' work.
- Use htop for a more visual and interactive process management experience.
- Document scheduled jobs and cleanup routines for future maintainers.
- Consider using systemd for advanced scheduling and service management on modern systems.