Cronjob run does not work

Hello all,

I’m new to Hestia and now struggling on with Command of CRON tab on user account. I’m trying to run a simple php file but it’s not working at all with those command:
/usr/bin/php /home/linhleo/web/

Sincerely and really appreciate for your supports.
Many thanks.

Hello @linhnguyen02,

Why do you think it is not working? What do you expect to happen when running that cron job?


Hello sahsanu, I’m testing to see if my command for Cron here is right and Cron will trigger php script to run.

test.php is just simple script that record time if this script fired by Cron job, but nothing happen at all.
I have tried other command also but nothing fired too:

That is easy to know:

grep 'CRON.*\(linhleo\)' /var/log/syslog

As you have enabled notifications, if the command has any output, you should receive an email in the email address assigned to your user.

What happens if you run the command /usr/bin/curl from terminal?

I haven’t received any email either for fail Cronjob.

Here’s the test.php:

<?php file_put_contents("test_result.log",date("Y-m-d H:i:s.v").PHP_EOL,FILE_APPEND); I'm not sure how to run this command on terminal /usr/bin/curl from terminal but here's the result: ![image|690x487](upload://rN2DTYqT60k2rcJvPJ1hIFFJcET.png)

I can’t view the uploaded image.

Could you please send it again or copy and paste the text (once copied the text, select it and click on button </> so the text will be shown as code)?

Also, send the output of this command:
grep 'CRON.*\(linhleo\)' /var/log/syslog

Sorry here is the screenshot for test.txt and command run

The command should be run as root, if your user has sudo permission use:

sudo grep 'CRON.*\(linhleo\)' /var/log/syslog

Regarding the curl command, as you can see, you can’t connect to your own server, you should solve it first.

Hello sahsanu,

Is there anyway that I can grant sudo permission to user? Or anyway that I can let the user run Cron on their account?

If you manage the server, just login as root and run the command:
grep 'CRON.*\(linhleo\)' /var/log/syslog

Above command is to check that the cron job for the user is running so we can discard that issue. If it is running fine (it should), the problem is other, like you can’t connect to your own server…

I’m using VScode to run above command by remote user account. But can I check if is there anyway that I can setup Cron in UI directly (by user account).

Sorry for bother you but I’m really new with server setup or command. One of IT departments install this server for me so I have no idea how to grant connection to user account

If you don’t have perms to view /var/log/syslog you can’t see whether it is actually working but you can create a cron job that “should” be run without issues.

Just create a new cron job (like you created the others) and use this command:

/usr/bin/date >>/home/linhleo/web/ 2>&1

Wait a couple of minutes and check the contents of file /home/linhleo/web/

If you are having issues, it should be easier to ask your IT team for help.

I have solved the problem and figured out because of syntax of PHP I have put in the file (forgot ending ?>). This have to be:

<?php file_put_contents("test_result.log",date("Y-m-d H:i:s.v").PHP_EOL,FILE_APPEND); ?>

Thank you for your support, sahsanu. Really appreciate.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.