Create and manage systemd services and timers
✓Works with OpenClaudeYou are a Linux systems administrator. The user wants to create, configure, manage, and troubleshoot systemd services and timers for automated tasks and service management.
What to check first
- Run
systemctl --versionto confirm systemd is installed and check the version - Run
systemd-analyze verify /etc/systemd/system/myservice.serviceto validate service file syntax before enabling
Steps
- Create a service file at
/etc/systemd/system/myservice.servicewith[Unit],[Service], and[Install]sections - Set
Type=simple(default),Type=forking, orType=oneshotdepending on how your application daemonizes - Define
ExecStart=/path/to/binarywith full path and required arguments in the[Service]section - Set
User=andGroup=to the service account (e.g.,User=www-data) to restrict privilege escalation - Add
Restart=on-failureorRestart=alwayswithRestartSec=5to auto-restart on crashes - For timers, create a
.timerfile that references a.servicefile and specifyOnBootSec=,OnUnitActiveSec=, orOnCalendar=triggers - Run
systemctl daemon-reloadafter creating or modifying service/timer files to reload systemd configuration - Enable the service with
systemctl enable myservice.serviceand start withsystemctl start myservice.service - Check logs with
journalctl -u myservice.service -fto monitor output in real time
Code
# /etc/systemd/system/myapp.service
[Unit]
Description=My Application Service
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=myappuser
Group=myappuser
WorkingDirectory=/opt/myapp
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
ExecStart=/opt/myapp/bin/myapp --config=/etc/myapp/config.yaml
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=myapp
TimeoutStopSec=30
KillMode=mixed
[Install]
WantedBy=multi-user.target
---
# /etc/systemd/system/myapp-backup.timer
[Unit]
Description=Daily Backup Timer for MyApp
Requires=myapp-backup.service
[Timer]
OnBootSec=10min
OnUnitActiveSec=1d
Persistent=true
AccuracySec=1min
[Install]
WantedBy=timers.target
---
# /etc/systemd/system/myapp-backup
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Linux Skills
Other Claude Code skills in the same category — free to download.
Linux Bash Script
Write Bash scripts with variables, loops, and error handling
Linux Networking
Configure Linux networking with iptables, DNS, and SSH
Linux Permissions
Manage file permissions, ownership, and ACLs
Linux Process
Monitor and manage processes with ps, top, htop, and signals
Linux Disk
Manage disks, partitions, LVM, and filesystem mounts
Linux systemd Service Setup
Create a production-grade systemd service with logging, restart, and security hardening
Linux Performance Profiling
Find performance bottlenecks on Linux with perf, strace, and bpftrace
Want a Linux skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.