Plesk

How to ensure that the cron service is working on a server

Question

How to ensure that the cron service is working on a server?

Answer

  1. Connect to a Plesk serer via SSH.

  2. Check if the cron process is running with the following command:

    # ps ax | grep cron | grep -v auto
    135 ?        Ss        0:00 /usr/sbin/crond -n

  3. Add a sample task to test the cron service:

    3.1. Run the command:

    # crontab -e

    3.2. Add the following line at the end of the file:

    * * * * * /bin/echo "foobar" >> /root/cron-test.txt

     3.3. Save changes and close the file. 

    3.4. After a minute, a text file /root/cron-test will appear with the word "foobar" in it and corresponding lines will appear in the cron logfile /var/log/cron.
    If the file was created, cron is working fine.

    3.4. Remove the line from crontab added on step 3.2.

  4. If some scheduled task is not running, check the cron logfile to find out if this scheduled task was started or produced any errors:

    # less /var/log/cron

Exit mobile version