PhyrePanel/bin/cron-jobs-list.sh

8 lines
346 B
Bash
Raw Normal View History

2023-11-27 18:59:11 +00:00
#!/bin/bash
2023-11-27 13:36:50 +00:00
# Replace 'username' with the actual username you want to retrieve cron jobs for
username=$1
# Get the user's crontab entries and convert them to JSON
crontab -u $username -l | grep -v -e '^#' -e '^\s*$' | awk '{print "{\"schedule\":\"" $1 " " $2 " " $3 " " $4 " " $5 "\", \"command\":\"" substr($0, index($0,$6)) "\"}"}' | jq -s .