Usage How to add a cron job on Linux
June 29, 2024 at 4:56 AMIf you want to use the Synchronize to WordPress/AD feature you need to set up a cron job. On Linux operating systems you can use Crontab to accomplish this.
Create a script
- First of all you have to create a script. For example “synctowordpress.sh”. This script has to contain the command you want to run. To trigger NADI “Sync to WordPress” add the command displayed on the “Sync to WordPress” in your WordPress environment. In NADI 2.0.14 the command includes a space by mistake between “http://yourdomain.local/wordpress” and “/wp-admin/admin.php”. Please remove the space.
- After creating your script you have to make it executable by typing “chmod +x nameofyourscript.sh”
- You can now test your script by typing ./nameofyourscript.sh
- If everything works correctly “Sync to WordPress” should be executed. You can check it by putting a tail on the debug.log file.
Add the scheduled task
-
Now that we got our script working we can add it to crontab. To do so please type crontab -e.
-
This task would execute your script 5 minutes after midnight every day.
5 0 * * * /path/to/synctowordpress.sh
Useful links
- If you need further information about the crontab syntax please take a look at the following page https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/