Setup a cronjob for php file

Welcome and Happy New Year @ishant

See this Setup a cronjob for a php file - #8 by josephgodwinke

* * * * * root /usr/bin/wget -O - https://website.com/export-txt.php >> /home/mydomain.com/public_html/output.txt

I can’t understand what does it mean?
plz help me @josephgodwinke

crontab-syntax

/usr/bin/wget -O - will retrieve content from your url, get as a file and print the result on STDOUT which we save to a sink /home/mydomain.com/public_html/output.txt

output.txt is automatically build

You can create it. This file can be any name you prefer. Well some developers do not put sinks for their cronjobs but it the ideal way to catch errors and exceptions

but in case of cron on the other cpanel you can only use your php file not other file

Have you tested and it has failed ?

No, now i will go through it.


it seems like this…what next?
nano /etc/crontab

You have not read this part

i have to add after the * * * * * root /usr/bin/wget -O - https://website.com/export-txt.php >> /home/mydomain.com/public_html/output.txt

=> website.com is my website domain and export-txt.php is my php file
home/mydomain.com/public_html/output.txt => mydomain.com is also my domain

Do you see the expected results ?

-bash: /home/project1.leofox.net/public_html/output.txt: Permission denied
i got this

Did you create that output.txt file on documentroot via file manager ?

yes, i do.

As you see the file has permissions rw–r–r change them to 777 and try again