am1ncmd
November 26, 2022, 9:12am
1
Hi there, I want to setup cronjob using curl
as example
curl --silent 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
Welcome @am1ncmd Happy you are here
You are trying to setup a cronjob for a php file. Psst that should be the title.
Solution:
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
am1ncmd
November 26, 2022, 10:11am
3
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?
am1ncmd
November 26, 2022, 10:38am
5
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
am1ncmd
November 26, 2022, 10:53am
7
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.
am1ncmd
November 26, 2022, 11:51am
9
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
system
Closed
November 26, 2022, 3:13pm
11
This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.