GoAdmio Command Line: cronjob with /go/cronjob

/go/cronjob runs the shell scripts you place in three folders, one per schedule: Before a group of scripts starts, the command sends an email and a WhatsApp message saying that it is running. It is a simple way to add your own maintenance scripts to the server without writing cron entries. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Create a daily script
mkdir -p /var/go/cron/daily
printf '#!/bin/bash\n/go/clean\n' > /var/go/cron/daily/10-clean.sh

# Run the scripts now
/go/cronjob

[!WARNING]
The scripts run as the user who runs /go/cronjob, normally root. Anyone who can add or change files in /var/go/cron/ can run commands as root, so keep these folders writable by root only. Running /go/cronjob by hand starts every daily script immediately.

Examples

# Folder layout
/var/go/cron/daily/10-clean.sh
/var/go/cron/weekly/20-check-ssl.sh
/var/go/cron/monthly/30-report.sh

# A script needs only a first line that names the shell and the commands to run
#!/bin/bash
/go/checkssl

# Run the command every day at 02:00 and keep its output
0 2 * * * root /go/cronjob >> /var/log/go/cron/cronjob.log 2>&1

# See which scripts will run, in order
ls /var/go/cron/daily

Output

The command prints a heading before each group it runs, followed by whatever the scripts print:

Group Heading
Daily Daily Scheduling Files...
Weekly Weekly Scheduling...
Monthly Monthly Scheduling Files... followed by Weekly Scheduling...

The second line under the monthly heading is a typo in the script. It doesn’t mean the weekly scripts ran.

If a folder is missing or empty, or it isn’t the right day, that group prints nothing.

Output from your scripts isn’t saved by this command. If you run it from cron, redirect its output to a file. Every run is also logged with a timestamp, for example [Nov 20 02:00:01]# cronjob, to /var/log/go/cronjob.log.

See the full reference at /go/cronjob 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 *