Background Process Management
Managing background processes with projax.
Running in Background
Basic Background Execution
prx 1 dev -M
Multiple flags supported:
-M(shortest)--background-b--daemon
With Auto-Resolution
prx 1 dev -M --force
Runs in background and auto-resolves port conflicts.
Viewing Running Processes
List All Processes
prx ps
Output shows:
- Process ID (PID)
- Project name
- Script name
- Running time
- Command executed
- Log file location
- URLs (if detected)
Example Output
Running processes (3):
PID 12345: projax (dev) - 5m 30s
Command: npm run dev
Logs: /Users/username/.projax/logs/process-1234567890-dev.log
URLs: http://localhost:3000
PID 12346: Frontend App (start) - 2m 15s
Command: npm start
Logs: /Users/username/.projax/logs/process-1234567891-start.log
URLs: http://localhost:38124
Stopping Processes
Stop by PID
prx stop 12345
Stop All Processes
# Get PIDs and stop each
prx ps | grep -o 'PID [0-9]*' | awk '{print $2}' | xargs -I {} prx stop {}
Viewing Logs
Log File Location
Logs are stored in ~/.projax/logs/:
process-<timestamp>-<script>.log
View Recent Log
tail -f ~/.projax/logs/process-*.log
View Specific Log
# From prx ps output
tail -f /Users/username/.projax/logs/process-1234567890-dev.log
Workflow Examples
Start Multiple Projects
# Start all in background
prx 1 dev -M
prx 2 dev -M
prx 3 start -M
# Check status
prx ps
Monitor Logs
# Start project
prx 1 dev -M
# Get log path from prx ps
prx ps
# View logs
tail -f ~/.projax/logs/process-*.log
Stop All at Once
# Get all PIDs
prx ps
# Stop each
prx stop <pid1>
prx stop <pid2>
prx stop <pid3>
Process Management
Check if Process is Running
prx ps | grep "My Project"
Find Process by Port
prx ps | grep "3000"
Get Process Details
# Full details from prx ps
prx ps
# Or check process directly
ps aux | grep <pid>
Log Management
View All Logs
ls -la ~/.projax/logs/
Clean Old Logs
# Remove logs older than 7 days
find ~/.projax/logs/ -name "*.log" -mtime +7 -delete
Archive Logs
# Archive logs
tar -czf logs-archive.tar.gz ~/.projax/logs/
Best Practices
- Use background for long-running tasks: Dev servers, API servers
- Monitor with
prx ps: Check what's running - View logs when needed: Debug issues
- Clean up old processes: Stop when done
- Use
--forcewith background: Auto-resolve conflicts
Troubleshooting
Process Not Starting
- Check port availability
- Check log files for errors
- Try running in foreground first
Process Not Stopping
- Check if process exists:
ps aux | grep <pid> - Force kill if needed:
kill -9 <pid> - Check process file:
~/.projax/processes.json
Logs Not Appearing
- Check log directory exists
- Check file permissions
- Verify process is actually running
Related Documentation
- Basic Workflow - Getting started
- Troubleshooting Background Processes - Common issues