Create a cron job in DirectAdmin

If you have a webshop or other system that needs to perform tasks regularly, chances are you want to automate this. Suppose; as a webshop, you want a payment reminder to be sent every day to customers who are late with their payments. You do not have to do all this manually. If your ordering system has the option to use a cronjob, you can easily set this up in DirectAdmin.

For the WordPress Cron Job, you can immediately go here

What is a cronjob?

A cronjob is a task that repeatedly runs at a fixed time. For example, you can set it up so that the same task is executed every minute between ten and eleven o'clock in the morning. You can also have it run just once at ten o'clock. Or, for example, on the first day of the month, or every Saturday. You can also combine with a cronjob: for example, you want to run a specific task every Saturday at exactly seven o'clock in the evening. The advantage of such a cronjob is that you do not have to do this manually, but the system can execute the tasks automatically.

How do I add a cronjob?

Once you understand the usefulness of a cronjob and know which php-script you want to call, you can start setting up the cronjob. Setting up a cronjob is easiest with DirectAdmin. See this article on how to log in to DirectAdmin. 

Once logged into DirectAdmin, click on Advanced Features in the menu. And then Cron Jobs. You will then arrive at the page with all configured cronjobs.

Cronjobs in DirectAdmin

 Then you click on create cron job.

Now we are going to create the cronjob. To do this, you first need to determine when you want to run a cronjob. In our example, we want our script to run the same cronjob every minute between ten and eleven o'clock in the morning, every day. This can be quite intensive. If you only want to run your cronjob once a day at ten o'clock, replace the asterisk with a zero. In a cronjob, an asterisk stands for 'every'. So if you only want to run the script once a week, per day, or something similar, enter the correct numbers. You can find more about this in the English explanation on the DirectAdmin cronjobs page.

First, choose the hour. In our example, it is 10 o'clock in the morning. We want to run the cronjob every minute, on every day of the month, every month, and every day of the week. Next, DirectAdmin needs to know exactly where the script is located. In this case, the php-script is located in our /home/auwdomei/domains/uw-domein.nl/public_html directory. The PHP script is called 'cron.php'. The command will then be: '/usr/local/bin/php /home/auwdomei/domains/uw-domein.nl/public_html/cron.php'. Do not forget to put '/usr/local/bin/php' in front of the script, otherwise DirectAdmin cannot execute it!

Create cronjob in DirectAdmin

If you do not want to receive email from the cronjob, before clicking 'Create', click on the button: 'Prevent Email'. And then click 'Create'.

Editing

It is also possible to modify the cronjob later. For example, because the time is incorrect, or because you made a mistake in the command. To edit, click the pencil icon (edit) on the right. You can also delete the cronjob entirely by selecting the cron job and then clicking on 'delete'.

Edit:

Delete cronjob in DirectAdmin

Delete:

Receiving notifications

If you want to receive a confirmation of every k

time the script is executed? Then you can have the results sent via e-mail. Click on ‘Send all Cron output to E-Mail’, enter your e-mail address in the pop-up window and click on ‘Save’.

Enter your e-mail address:

If you can't figure it out, you can always contact our support department.


Still have questions? Get in touch.