Production-grade process management - jobs, signals, cron, systemd
Manage background jobs, send signals, and schedule tasks with cron. Use when you need to run long processes, control existing processes, or automate recurring commands.
/plugin marketplace add pluginagentmarketplace/custom-plugin-bash-shell/plugin install custom-plugin-bash-shell@pluginagentmarketplace-bash-shellThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyMaster process control, signals, scheduling, and monitoring
After completing this skill, you will be able to:
# List processes
ps aux # All processes
ps -ef # Full format
ps --forest # Tree view
# Find processes
pgrep -f "pattern" # PID by pattern
pidof nginx # PID by name
ps aux | grep '[n]ginx' # Grep trick
# Resource usage
top # Real-time view
htop # Better interface
# Send signals
kill PID # SIGTERM (15)
kill -9 PID # SIGKILL (9)
kill -HUP PID # SIGHUP (1)
killall nginx # By name
pkill -f "pattern" # By pattern
# Handle signals in scripts
trap 'cleanup' EXIT
trap 'echo "Interrupted"' INT
cleanup() {
rm -f "$TEMP_FILE"
exit 0
}
# Background execution
command & # Run in background
nohup command & # Immune to hangup
nohup cmd > log.txt 2>&1 & # With logging
# Job control
jobs # List jobs
fg %1 # Foreground job 1
bg %1 # Background job 1
disown # Detach from shell
# Cron format
# ┌─── minute (0-59)
# │ ┌─── hour (0-23)
# │ │ ┌─── day of month (1-31)
# │ │ │ ┌─── month (1-12)
# │ │ │ │ ┌─── day of week (0-6)
# * * * * * command
# Examples
0 * * * * # Every hour
*/15 * * * * # Every 15 minutes
0 0 * * * # Daily at midnight
0 0 * * 0 # Weekly on Sunday
# Edit crontab
crontab -e
crontab -l
start_daemon() {
nohup ./daemon.sh >> /var/log/daemon.log 2>&1 &
echo "$!" > /var/run/daemon.pid
disown
}
stop_daemon() {
if [[ -f /var/run/daemon.pid ]]; then
kill "$(cat /var/run/daemon.pid)"
rm /var/run/daemon.pid
fi
}
# Prevent overlapping runs
0 * * * * /usr/bin/flock -n /var/lock/job.lock /path/to/script.sh
#!/usr/bin/env bash
set -euo pipefail
cleanup() {
echo "Cleaning up..."
rm -f "$TEMP_FILE"
}
trap cleanup EXIT INT TERM
# Main logic
TEMP_FILE=$(mktemp)
# ... work with temp file
| Signal | Number | Default | Common Use |
|---|---|---|---|
| SIGHUP | 1 | Terminate | Reload config |
| SIGINT | 2 | Terminate | Ctrl+C |
| SIGQUIT | 3 | Core dump | Ctrl+\ |
| SIGKILL | 9 | Terminate | Force kill |
| SIGTERM | 15 | Terminate | Graceful stop |
| SIGSTOP | 19 | Stop | Pause |
| SIGCONT | 18 | Continue | Resume |
| Don't | Do | Why |
|---|---|---|
kill -9 first | kill -TERM first | Allow cleanup |
| Kill PID 1 | Never | Crashes system |
| Cron without logs | Log all output | Debug issues |
| Error | Cause | Fix |
|---|---|---|
No such process | Already dead | Check with ps |
Operation not permitted | Wrong owner | Use sudo |
| Cron not running | PATH issues | Use full paths |
# Check if process exists
ps -p $PID
# Debug cron
grep CRON /var/log/syslog
# Trace process
strace -p $PID
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.