/go/cron: cron from the Command Line

/go/cron writes the cron files that run GoAdmio's scheduled work. It manages two kinds of file in /etc/cron.d/: It can also restart or stop the cron service, and open the main file in an editor. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Rebuild the main cron file and restart cron
/go/cron

# Rebuild the cron jobs of one domain
/go/cron example.com

[!WARNING]
/etc/cron.d/go and the per-domain files are rewritten completely each time. Manual edits are lost. /go/cron stop stops the cron service, so no scheduled job on the server runs until you start it again with /go/cron restart.

Arguments

Argument Notes
<domain> Any argument that contains a dot is treated as a domain. /home/<domain>/www must exist.
restart, stop Run systemctl restart or systemctl stop on crond (AlmaLinux, Rocky, CentOS, Red Hat, Fedora) or cron (Debian, Ubuntu).
-e Edits the main file. Run it as root.

Any other argument, or none, rebuilds the main file.

Examples

# Rebuild the main cron file
/go/cron

# Apply changes to the cron jobs of example.com
/go/cron example.com

# Stop and start the cron service
/go/cron stop
/go/cron restart

# View the main cron file and the per-domain files
cat /etc/cron.d/go
ls /etc/cron.d

# Check the output of a scheduled job
tail /var/log/go/cron/hourly.log

# Check for cron errors
journalctl -u crond -n 20 # AlmaLinux, Rocky, CentOS, Red Hat, Fedora
journalctl -u cron -n 20 # Debian, Ubuntu

Output

The command prints nothing, except Domain <domain> does not exist. when the domain’s www folder isn’t found.

Every run is logged with a timestamp, for example [Nov 20 09:15:02]# cron example.com, to /var/log/go/cron.log. The output of the scheduled jobs themselves goes to files in /var/log/go/cron/, such as hourly.log and backup.log.

Domain, restart, stop, and -e runs, and the MinIO case described in Details, always exit with status 1, even when they work. Don’t use the exit status to check for success.

See the full reference at /go/cron and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *