FeedWordPress cron job code - cron

FeedWordPress (RSS fetcher) plugin of WordPress is working well, but it doesn't have an option to update RSS every 5 minutes (default is 60 minutes) so the only way is clicking the UPDATE NOW button manually.
I am new and some guys told me to trigger it every 5 minutes using a cron job, so I tried that in cpanel
First I tried this
curl http://domain.com/?update_feedwordpress=true > dev/null
but was getting this error
/bin/sh: dev/null: No such file or directory
Second I tried this
wget http://domain.com/?update_feedwordpress=1
but now I'm getting this error
/bin/sh: /usr/bin/wget: Permission denied
(I used my domain.com in that place)
Any correct/exact working code?

You can use this code:
/usr/local/bin/curl --silent -L "http://example.com/?update_feedwordpress=1" >/dev/null 2>&1
where you should replace example.com with your domain name.

Null device is /dev/null
The /usr/bin/wget does not seems to have permission to execute for the current user.
It may be easier to write a script (say mydebug.sh ) and run the script with cron
id
ls -l /usr/bin/wget
curl ...
Then check for any obvious errors due to permissions.

Related

How to use spaces within cron?

While trying to run a cronjob (I don't have access to the SSH terminal, I only have access to record crons via a cPanel from my hosting) I need to put a space between the cron command itself:
wget -o https://abc.de/aaaaa/bbb ccc/ddd >/dev/null 2>&1
However, the cron job fails reporting:
wget: Unable to find directory https://abc.de/aaaaa/bbb
So how can I use a space there?
In this case, URL encoding should do the trick:
https://abc.de/aaaaa/bbb%20ccc/ddd
but
wget -o "https://abc.de/aaaaa/bbb ccc/ddd"
should work as well.

How do I make AcySms manual cron job in cPanel work?

When setting up AcySMS, there are few option for the cron job. "Web cron" runs at the fastest interval of 15 minutes, way too slow for me.
I have opted for "manual cron", and am given the following "cron URL" https://www.followmetrading.com/index.php?option=com_acysms&ctrl=cron
Putting that into the cPanel cron job manager just leaves me with an error everytime the cron attempts to run:
/usr/local/cpanel/bin/jailshell: http://www.followmetrading.com/index.php?option=com_acysms: No such file or directory
I have discovered that the following command executes the script properly.
curl --request GET 'https://www.followmetrading.com/index.php?option=com_acysms&ctrl=cron&no_html=1' >/dev/null 2>&1
Note: ensure the URL is surrounded by ' ' otherwise it seems to miss everything from the & onward.
Note: >/dev/null 2>&1 makes sure there is no email trail.

Cronjob command not working, despite having the same format as other commands that DO work

Trying to add a new cronjob to my server using Plesk. I have two running already, but it's so long since I set them up that I can't remember why I did it the way I did. They work exactly as they should.
*/13* * * * &> /dev/null php -q httpdocs/forum/notifyreply.php
*/9 * * * * &> /dev/null php -q httpdocs/forum/notifytopic.php
However, when I add my new job using the same format, it doesn't seem to do anything. The script doesn't run and I get no e-mail notification to tell me that the script has run. The new job is as follows:
* * * * * &> /dev/null php -q httpdocs/crm/autoMessages/autoEmail.php
I'm running these on a Linux Virtual Server with Apache and using Plesk Control Panel. Hosting provider is 123-Reg.
Can anyone help?
Thanks!
UPDATE
So I've now removed the /dev/null line so I receive e-mail notifications and I'm getting the following error message:
/bin/sh: php: Permission denied
What I don't understand is why permission is being denied on this command but not on the other two...
Not sure what could have happened, but first thing I would do is to check if the permissions for the new php script are the same as what the old ones have. Do a ls -l on both httpdocs/forum/notifyreply.php and httpdocs/forum/notifytopic.php, and compare the permissions against what httpdocs/crm/autoMessages/autoEmail.php have.
You are not setting a User/Group for the cron command, better do it like this
* * * * * www-data www-data php -q httpdocs/crm/autoMessages/autoEmail.php > /dev/null 2>&1
(assuming that www-data is the correct User)
note that I put the error handling at the end.
Also, I think that you should use the full path; either you forgot to add a slash ( /httpdocs/.... ) , or do you have this script in the cron folder?

Using Cron to open and visit URL's

I've been working on a script to run from /etc/cron.daily to run everyday at 5:00 AM, script works but it doesn't seem to run after I've set all the right executive permissions.
My script is using XDG-OPEN to open up a website in a web browser, but even after setting permissions to execute, ie; chmod +x it doesn't run like it's suppose to. because in my own crontab ->> crontab -e I've made my cron job scheduled to run at 5:00AM everyday linking to the script inside of /etc/cron.daily
here's my script that I use so get clear picture how it's setup;
#!/bin/sh
LOG=/var/log/website_open.log
DATE=`date +'%a, %e %b %T %p'`
echo "*** Website opened on [ $DATE ]***" >> $LOG
echo " " >> $LOG
xdg-open http://example.com | grep -v "Created new window in existing browser session." >> $LOG
When I check the log it says it executed on which date, but it's not been doing what it's suppose to. So the logs would say this
*** Website opened on [ Mon, 24 Nov 01:04:41 AM ] ***
but it didn't really execute it properly. I did do run-parts -v to check if it worked alright, and it does, cuz it did execute properly and opened up the website after running that, but the problem is Cron isn't running it like when I tested it with run-parts -v for some reason. It's like it's being ignored, there doesn't seem to be a permission issue, because if it did it would of shown up in the logs like "Google Chrome can not run as Root" since that's my default browser to run as.
I don't believe there is anything wrong with my script since xdg-open http://example.com runs as expected from the script when tested, and in my crontab when I do crontab -e I have it set like this;
0 0 5 1/1 * ? * /etc/cron.daily/example_com
but still doesn't execute as it should be. I have thought about whether I should just execute the script from my home directory and using it with crontab, but I don't really like how crontab works since it only creates a temporary file like this;
/tmp/crontab.CjOKO9/crontab
and I just want it to be in an actual script of it's own it just runs from instead of being in a temporary file, not sure if that's entirely possible since I want it to run as my user account name and not root.
For some reason xdg-open doesn't work correctly when used in association with crontab.
You can tweak your way around to get the job done by using any of the following commands :
chromium-browser http://www.google.com
or
firefox http://www.google.com
based on your browser.

Adding a cronjob into cPanel

I just need to run the following url using cron jobs in my cPanel.
When I am trying to execute the link
http://www.insidewealth.com.au/index.php?option=com_acymailing&ctrl=cron
the link is running in browser but when I am tried to add the same URL as it is in cron jobs I am getting the following error
bash/sh/ file not found
and when I edited the cron job as
/usr/bin/php /home/staging/public_html/index.php?option=com_acymailing&ctrl=cron
but I am getting 404 error.
My cPanel username is staging
Can anybody tell me what's the syntax of cron job in cPanel.
Cron Job running every minute and email report showing this errors.
Use wget function with full URL.
#yannick-blondeau As suggested you can use a wget or curl to make a simple request to your website.
Usually wget will attempt to download a file but this is not necessary with the -O flag to pipe to /dev/null or -q (both options used to prevent from saving output to a file), an example will look like
wget -O /dev/null http://www.insidewealth.com.au/index.php?option=com_acymailing&ctrl=cron
wget -q http://www.insidewealth.com.au/index.php?option=com_acymailing&ctrl=cron
You can also use curl for the same effect
curl --silent http://www.insidewealth.com.au/index.php?option=com_acymailing&ctrl=cron

Resources