Cron job backup remote folder to local folder with wget over ftp - cron

Hi everyone would do with some advise
Can not get this simple task working
0 17 * * * wget -m ftp://usarname:password#host.com:port/remote/folder -P /local/folder
what im doing wrong ?
if i run it in terminal line:
wget -m ftp://usarname:password#host.com:port/remote/folder -P /local/folder
it is working as expected but if i add under crontab -e nothing happens.
I would like cron job to check files every day at 17:00 for changes.
thanks in advance

Forgot to restart cron service. Now just need to make it all end to end encrypted.
if you make any changes to services do not forget to restart them :)
restart cron

Related

Cron job is not triggered on Ubuntu VM

Ubuntu
In my Ubuntu VM, I have configured a cronjob
cat /var/spool/cron/crontabs/*
MAILTO="myemail#gmail.com"
* * * * * python /home/forge/web-app/database/backup_mysql.py
I checked pgrep cron I got number printing out fine.
It been 5 mins now, I don't see any email send to me.
I don't see any backup file is being generated.
I have a feeling that this cronjob never got run.
How do I debug this ?
Do I need to restart some kind of service ?
Could you please check the cron service.
service cron status.
And check the cronjob logs to check it is running or not
tail -f /var/log/cron | grep username
Check the cron
crontab -e -u username
And also check permission.
chmod +x <file>

Run cron job hourly

I use let's encrypt for getting certificates and I want to setup renewal for certificates.
So, I decided to check if cron works fine.
I created three file in daily.hourly folder:
test-h:
/sbin/ifconfig >/home/bitnami/ipt
test-h2:
#!/bin/bash
/sbin/ifconfig > /home/bitnami/ipt2
test-h3.sh:
#!/bin/bash
/sbin/ifconfig >/home/bitnami/ipt3
But, I don't see my files in home directory. How to properly use cron.daily?
PS. The cron servive is started, I checked.
I restarted it also just to make sure that changes is applied.
The crontab file contains record for cron.hourly:
17 * * * * root cd / && run-parts --report /etc/cron.hourly
I am not linux guy, so, if it possible get me detailed answer please.
The problem is you didn't chmod +x your scripts. That's needed to make them executable.

Implement cron schedular in linux

I am trying to execute a php script in my linux server. the script will run everyday at 8 am. I have uploaded my crontab in linux server and the php file update1.php Script in my crontab is given below. But this isnt updating my databse. where am i doing wrong ? Am i missing something here. Thanks in advance.
crontab
0 8 * * * http://www.mywebsite.com/update1.php
You can use --spider option of wget for this purpose.
0 8 * * * wget --spider http://www.mywebsite.com/update1.php
--spider indicates not to download anything (we just want to go through the pages, that’s all)
This line/code in your crontab:
http://www.mywebsite.com/update1.php
is not an execution of the script, it's just the url to it. You should download the php script, and put it locally on your linux server. That would make things simpler and much more reliable.
I would login to your linux server, use wget to download the script, chmod it to make sure it's executable, and mv it to wherever you want on your server:
wget http://www.mywebsite.com/update1.php -O update1.php
chmod 755 update1.php
mv update1.php /path/to/where/you/want/script
Then now that you have the script locally on your linux server, edit your crontab (crontab -e), and add the following line:
0 8 * * * /path/to/where/you/want/script/update1.php

How to setup cron job on Amazon Linux AMI

I am hosting Tiny Tiny RSS site hosted on
Amazon Linux AMI
To update the feed automatically I have to run the following Cron job.
Reference
http://tt-rss.org/redmine/projects/tt-rss/wiki/UpdatingFeeds
*/30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet
Here is the step I did:
sudo su
cd /etc
crontab -e
# add this line
*/30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet
But I still got the message "Update Daemon is not running".
May I know, is this correct step for Cron job?
You should enter these commands on Amazon Linux 2:
sudo systemctl start crond
sudo systemctl enable crond
This sounds like crond is not running. In which case:
service crond start
chkconfig crond on
You should first inspect the cron log file /var/log/cron and look for any errors. This will probably give you the answer. Also make sure you can run the command successfully on the command line (/usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet).
Please check the spaces, it could be because of spaces are not placed correctly
Simply do : * * * * * wget -o - -q -t 1 "your url with cron file"
Please remove the "--quiet" part from your cron command and check the log and feed again

FeedWordPress cron job code

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.

Resources