I need to create a cron job that runs a webpage (and retrieve some data) (not a file on the server). I tryed wget and it works if I set the cron job manually in unix, but not if I create the cron job in cpanel. Something like wget -O http://someurl.somehting.
cron jobs do not run under your user and environment. The path to wget may not be in the cron user's PATH. Specify the full path (e.g. /usr/bin/wget).
Related
i have problems with Cron jobs, it's always said "No such file or directory"
I tried everything but it's still not working on that cPanel.
-q /home/user/tracker.domain.com/cron/3.php
It's using subdomain who is not in public_html.
You have to specify the full php binary path inside the cronjob. Assuming your php binary full path is /usr/bin/php then your cronjob will look like this:
/usr/bin/php -q /home/user/tracker.domain.com/cron/3.php
You should use php before -q in your cron jobs like this
php -q /home/user/tracker.domain.com/cron/3.php
I have set up cron jobs for my SugarCRM as requested by Sugar:
But when we look at last runs it does not seem to work or show anything.
I am using this for email reminders, mail check and also scheduled campaign run.
Is command-line php on your system installed and the executable in whatever PATH that cronjob is using?
If not make sure to specify the full path, e.g. /usr/bin/php or /usr/local/bin/php are common.
Also based on your operating system/distribution the php command line executable may have a different name, e.g. php5.
Make sure to use the web-process user's crontab or execute php with sudo -u webprocessusername, so that the cronjob will be executed with the correct permissions.Running the cronjob as different user or even root is usually not a good idea.
To see potential error messages replace > /dev/null e.g. with > /tmp/sugarcron.log or > /path/to/webfolder/sugarcron.txt and check the file after a minute.
Further info on the SugarCRM Knowledge Base:
Introduction to Cron Jobs
Troubleshooting Cron and Schedulers
in the logrotate manpage, they say:
"Normally, logrotate is run as a daily cron job".
Does that mean that logrotate uses cron (or is executed by cron)?
If so, does that mean that if I don't configure a cron job via crontab (for instance), logrotate will not work?
You CAN run logrotate manually WITHOUT cron.
logrotate <configuration file>
However if you want to run logrotate on a scheduled basis, yes you will need cron.
Your package manager should create a default schedule in /etc/cron.daily/logrotate that runs logrotate with the default /etc/logrotate.conf configuration. You can also place your custom configurations in /etc/logrotate.d/ since the default configuration has a line that include all configurations in this directory.
include /etc/logrotate.d
If you want to run logrotate with a custom schedule, you can place your cron job in /etc/cron.d/.
For example, this would trigger logrotate using /etc/custom-logrotate.conf configuration every day at two o'clock.
0 2 * * * root /usr/sbin/logrotate /etc/custom-logrotate.conf
Checkout crontab guru if you need help with cron expression.
Yes, normaly, cron executes logrotate on a daily base.
I depends on your linux distro, but the normal is to have cron running it.
You can check if have the file /etc/cron.daily/logrotate
If thats the case, you distro uses cron to run logrotate.
If you are using docker, this can bring some problem, currently cron doesn't run inside a container.
Is it possible to run a cron job on host that also saves a file to your website directory? I have an API I download a xml file from hourly. I would like to schedule cron to automate this but I'm not sure if it's possible.
You can write a cron job to execute an arbitrary script. The script can do whatever you like provided it has the appropriate permissions.
* * * * * /bin/execute/this/script.sh
Will run the script script.sh
You need to configure the crontab entry appropriately (obviously).
Yes. You can schedule a script in cron.
In the script you can add lines to generate the file and to place the file in the location you want.
Note: Be sure that you have permissions to create a file in that specific location path.
I have a php script that deletes a file from a specific folder on my server:
if (file_exists($_SERVER['DOCUMENT_ROOT']."/folder/file1"))
{
unlink($_SERVER['DOCUMENT_ROOT']."/folder/file1");
}
When I go to this script address with my browser it works fine.
I created a cron job to run this script every hour and running this script from the cron job - the file is not deleted.
I also created a flag that send me an email and I suspect that the cron job gets a false response to the "file_exists" test and not continue to the "unlink" action.
Any idea why cron job wont delete the file?
Thanks
Anyone??
Solved it:
Instead of $_SERVER['DOCUMENT_ROOT']."/folder/file1
Had to put this: /home/public_html/folder/file1