November 26, 2022, 9:12am
Hi there, I want to setup cronjob using curl
https://website.com/export-txt.php > /home/cyberpanel/public_html/output.txt
I have tested that command directly via terminal and its working
but somehow I set it on cronjob and it did not work
is it need to use using different command to use in cronjob?
Oh anyway, I install cyberpanel on VPS Ubuntu 20.04
Thank you in advance
@am1ncmd Happy you are here
You are trying to setup a cronjob for a php file. Psst that should be the title.
php /home/mydomain.com/public_html/test.php >> /home/mydomain.com/public_html/output.txt
To use a different PHP version:
/usr/local/lsws/lsphp81/bin/php /home/mydomain.com/public_html/test.php >> /home/mydomain.com/public_html/output.txt
For quiet mode:
php -q /home/mydomain.com/public_html/test.php >> /home/mydomain.com/public_html/output.txt
November 26, 2022, 10:11am
The reason why I use CURL instead of PHP is the source
https://website.com/export-txt.php is using different website
I already tried using the PHP command but the output.txt is still not showing on the directory
Also, thank you for suggesting the tittle
Does the world have access rights to that php file?
November 26, 2022, 10:38am
I own that website, just using different hosting and also a different panel
cyber panel installed on VPS, and the other one is using the default panel from the hosting itself
Am asking can you access
https://website.com/export-txt.php via curl on your pc
November 26, 2022, 10:53am
Yes, of course, It can be access it from anywhere on any devices
Try the system wide cron
nano /etc/crontab add this line at the end to run every minute so that we confirm if it ran:
* * * * * root /usr/bin/wget -O - https://website.com/export-txt.php >> /home/mydomain.com/public_html/output.txt
why wget its just my preference.
November 26, 2022, 11:51am
Alright, this one is working using curl. Thank you so much
But I still have a question: why is not working with the default cronjob from the cyber panel?
All cronjobs are here
/var/spool/cron/crontabs you can always view your conrjobs by running
crontab -l I believe the trick was running as root OR it failed during creation in cyberpanel. Can you check your logs for any errors
November 26, 2022, 3:13pm
This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.