6
votes

i need to create cron job to run URL from Cpanel every minute
when i open the link from browser it's auto generate backup for database

i choose the common setting ( once per minute ) * * * * *
and this is the command i use but no one worked

GET http://example.com/backup > /dev/null
wget http://example.com/backup
curl -s http://example.com/backup > /dev/null
wget -q -O /dev/null "http://example.com/backup" > /dev/null 2>&1

this is my references
https://forums.cpanel.net/threads/cron-job-to-call-a-web-page.60253/
Using CRON jobs to visit url?
CRON command to run URL address every 5 minutes

3
Define "no one worked". Did you get an error message? Did you try the commands interactively (instead of having cron execute them) ? Have you tried redirecting the output of your commands to a log file and inspecting it? - Frank Schmitt
@FrankSchmitt no error message appears i tried the link directly and it's working, how to commands interactively or redirect the output of my commands to log file and inspecting it ?? - Mohamed Mehanny
Instead of redirecting the output to /dev/null, redirect it to a log file, e.g. via command > /tmp/cron-log.txt - Frank Schmitt
@FrankSchmitt thanks for your help, i get the error that code redirect to login page because it's required to be login to create backup , i change auth for it and working :) - Mohamed Mehanny

3 Answers

14
votes

use this

wget -q -O - http://example.com/backup >/dev/null 2>&1

instead of

wget -q -O /dev/null "http://example.com/backup" > /dev/null 2>&1
2
votes

wget -q -O /dev/null "http://example.com/backup" > /dev/null 2>&1

1
votes

You can use "links" command like:

links https://www.honeymovies.com