Bobcares

Here’s how we set up Webmin cron

by | May 14, 2019

Cron is one of the most useful utilities in Linux operating systems.

It allows running scheduled tasks like disk space monitoring, system maintenance easy.

In Webmin, there is a feature to set up cron jobs that make users schedule task when they are out of workplace.

At Bobcares, we often get requests from our customers to configure “Webmin cron” as part of our Server Management Services.

Today, we’ll see how our Support Engineers add cron jobs in Webmin and fix the related issues with it.

 

 

How we set up Webmin cron

Setting a cron job is a great way to automate a specific task in Webmin.

Let’s see how we configure cron jobs in Webmin by following the steps below.

1. Initially, we log in to Webmin admin panel.

2. Next, we navigate to Webmin> System> Scheduled Cron Jobs.

3. Then, we click the Create a new scheduled cron job button.

4. In Execute cron job as field we select the user & enter the script in Command field.

5. And under When to execute section we select Times and dates selected below to enter the minutes, hours, days, months, weekdays.

6. Finally, to test the cron job click Save and Run Now.

Now, you can see all the listed scheduled cron jobs like this.

 

Common errors & fixes after setting cron job in Webmin

Even after configuring cron job in Webmin, we often see some common errors.

Let’s take a closer look at each one of them & how our Support Engineers fixed it.

 

1. Wrong command in cron

Recently one of our customers reported us that after setting the command in cron job to automatically make PC sleep & wake every day, it failed to run the task. The command is:

/usr/sbin/rtcwake -m mem -l -t $(date +\%s -d 'tomorrow 07:20')

This happens because the command entered was incorrect and it failed to execute.

So, to solve the problem we took the following steps.

1. First, we checked the cron log file to see the cron jobs.

 grep "CRON" /var/log/syslog

2. We found that the cron command truncates like this:

/usr/sbin/rtcwake -m mem -l -t $(date +\%s -d 'tomorrow 07:20')

3. In Webmin, special character % is masked automatically as \%. So, we corrected the command as:

/usr/sbin/rtcwake -m mem -l -t $(date +%s -d 'tomorrow 07:20')

4. Finally, we restarted the service.

systemctl restart crond.service

That fixed the problem & the user could execute the cron job.

 

2. Incorrect Permission

Similarly, another customer approached us with a problem after executing crontab, it resulted in an error like “/usr/bin/crontab: Permission denied”.

Often this error happens when the corresponding user doesn’t have the permission to execute the cron job.

As a result, it prevents the Webmin cron module to work properly.

So, to solve this error we performed the following steps.

1. First, we checked the list of users.

ls /var/spool/cron/crontabs

2. Next, we checked the user permission by running this command:

ls /usr/bin/crontab

3. By analyzing, we found that the user didn’t have any permission. So, we granted permissions by running this command:

chmod 2755 /usr/bin/crontab

4. Finally, we restarted the services.

That fixed the problem & the user could run the cron job without any failure.

 

3. Broken PHP module

Sometimes crontab does not work if the PHP module is not properly installed. PHP script executed with a cron job requires a specific php.ini file.

To execute cron job correctly we installed PHP on the Webmin server by running the command:

apt-get install php7.0-cli

Once PHP installed, we executed the PHP command & the cron job like this.

php /var/www/example.com/public_html/crons.php

 

[Having trouble after setting cron job in Webmin? We’ll fix it for you.]

 

 

Conclusion

To be more precise, the cron job help users to schedule tasks that make it easier. Today, we saw how our Support Engineers configured Webmin cron & fixed the top 3 common errors related to it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.