- Login as root user through SSH (I prefer putty)
- To view crontab entries execute the following command:
- To edit crontab directly you can use:
But for bulk editing it’s not really convenient, right?
Instead, we’ll create an editable file with all needed entries first and then load it to crontab.
- Prepare crontab entries in regular .txt.
For WordPress Multisite Cron it will look something like this:
1 0 * * * wget -O 'http://siteA.com/publishing.php' >/dev/null 2>&1 2 0 * * * wget -O 'http://siteB.com/publishing.php' >/dev/null 2>&1 3 0 * * * wget -O 'http://siteC.com/publishing.php' >/dev/null 2>&1
or you can use curl instead:
1 0 * * * curl -L -s 'http://siteA.com/publishing.php' >/dev/null 2>&1 2 0 * * * curl -L -s 'http://siteB.com/publishing.php' >/dev/null 2>&1 3 0 * * * curl -L -s 'http://siteC.com/publishing.php' >/dev/null 2>&1
I won’t explain here crontab syntax in detail as there are loads of instructions you can easily find.
2. Create file in desired directory (that’s my root in Centos):
cat > /var/www/www-root/data/my_cron.txt
This will create file and open it for editing at once.
You can edit it right here (
ctrl-c to past prepeared lines,
ctrl-d to save ) or even through FTP if it’s more convinient to you.
Mind, that the next step will replace all existing entries in your current crontab. So in order to preserve them, remember to add them to your my_cron.txt as well.
3. Update crontab with new values:
4. List cron jobs to verify your crontab has been updated correctly:
Not that complicated, right?
From now on when it comes to corn jobs you won’t waste your time anymore adding them manually.
Better, enjoy an extra cup of coffee instead 🙂