unix cron
Overview of Task Manager in Windows
- Definition of a Process in Operating Systems
- A process is a program or a task that is being executed by the operating system.
- Processes can be associated with various functions, such as memory management, file management, and application running.
Hierarchical Structure of Processes
- Processes have a parent-child hierarchy.
- A parent process can create child processes when starting new tasks.
- Example: When opening a new tab in a web browser, a main process (browser) generates a child process for that tab.
Understanding CPU and Memory Usage
top Command - Used to display the current status of processes in the system.
- Typing
top presents an interactive table that shows: - PID (Process ID): Unique identifier for every process. It's static once assigned.
- User: Owner of the process, e.g.,
root, or an application user. - CPU Usage: Percentage of CPU being utilized by each process, along with overall CPU statistics.
- Memory Usage: Percentage of memory being utilized, updated interactively.
- Tasks Information: Number of processes running, sleeping, stopped, and zombie processes.
- Example: A process in a "sleeping" state is waiting for some resource like network data.
- Zombie Processes: Completed processes that still have an entry in the process table, wasting resources.
Alternative Command: htop
htop is an enhanced visual version of top with user-friendly interface - May require installation on your operating system.
- Displays cores of the processor with a more visually appealing layout.
- Offers features to control and interact with processes more easily (e.g., KILL command).
Memory Management Commands
free Command - Shows memory usage in the system, providing:
- Total memory, used memory, free memory, and buffer statistics.
- Virtual Memory:
- Introduced to simulate additional memory on disk when physical RAM is full.
- Swap space:
- Virtual memory on disk, created by the operating system to extend RAM capacity.
- Utilizes processes during periods of high memory usage.
Process Management Commands
ps Command - Displays information about current processes, with options like:
ps -e to list all processes.ps -u username to filter processes by a specific user.ps aux for a detailed overview of all processes running with their usage statistics.
uptime Command - Displays how long the system has been running alongside the number of connected users.
Scheduling Commands
- Cron Daemon
- A system service that runs scripts or commands at specified intervals.
- Crontab Command: Used to create or manage scheduled tasks.
- Syntax example:
* * * * * command - Corresponding fields: minute, hour, day of month, month, day of week.
Example Cron Job:
- Task: Backing up a folder at midnight every Sunday.
- Example crontab entry:
0 0 * * Sun tar -czvf /backup/myfolder.tar.gz /home/myfolder- Breakdown: At 00:00 on Sunday, create a gzipped tarball of
myfolder.
Additional Topics
- Killing Processes: Can use commands such as
kill to stop unwanted processes. - Managing CPU Priority with
nice:- Adjusts the priority level of processes to influence CPU scheduling.
Code and Project Development Notes
- Guidelines to develop project commands and scripts in shell files that can be scheduled through Cron.
- Keep practice focused on process management, scripting for automation, and memory usage optimization.
- Example Objective: Create a backup service that automatically runs .