Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- user=''
- host=''
- # Install dependencies
- if ! command -v go >/dev/null; then
- brew install go
- fi
- if ! command -v cronv >/dev/null; then
- go get github.com/takumakanari/cronv/cronv
- go build -o ./cronv github.com/takumakanari/cronv/cronv
- mv ./cronv /usr/local/bin
- fi
- # Generate crontabs and reports for each user on the host
- crontab_path="./crontab/${host}"
- mkdir -p "${crontab_path}"
- report_path="./report/${host}"
- mkdir -p "${report_path}"
- for host_user in $(ssh "${user}@${host}" 'cut -f1 -d: /etc/passwd'); do
- crontab_file="${crontab_path}/${host_user}.crontab"
- ssh \
- "${user}@${host}" \
- "sudo crontab -u ${host_user} -l" \
- 1>"${crontab_file}"
- if test ! -s "${crontab_file}"; then
- rm "${crontab_file}"
- else
- cronv \
- --duration 1d \
- --from-time '00:00' \
- --title "${host_user}@${host}" \
- --output "${report_path}/${host_user}.html" \
- < "$crontab_file"
- fi
- done
Add Comment
Please, Sign In to add comment