How to set up automatic connection to sites using wget - wget

Hello I would like to ask if it can not connect automatically to the site at 09:00 AM using wget
It would be nice if I did not have to open the page manually for points each day.
Thanks

you can schedule an cron job
then use below commands
$ crontab -e
$ 00 09 * * * /path/to/script.sh
more description on
here
if you are on windows then you can use task scheduler inbuilt given in windows

Related

Crontab doesn't backup postgre DB in docker, but if i run script by hand it work prorely

I'm trying to set up automatic backup for postgre database. Postgre running in docker, so my script for backup is:
docker-compose exec postgres -U user database_name | gzip > "/var/server/my_service/data/backup-db/db_backup.sql.gz"
And its working fine, if I run it manually. I wrote the following job for the crontab (every 5 minutes just for testing):
*/5 * * * * cd /var/server/my_service && sh /var/server/my_service/data/backup/backup_script
This command also working great, if i run it manually it create valid DB backups that i can use.
But crontab just create empty archive, without any data. I just cant understand why.
My guess is that the output stream that catches the gzip is normally generated in manual mode, but completely empty when the crontab trying to run command
I thought there were problems with access rights and put the in the root crontab but it didn't help
UPD:
so... problem in backup_script, error in logs says the input device is not a TTY
I tried google it and add -T, but it didn't help as well
Update your /var/server/my_service/data/backup/backup_script with the following:
Prefix the first 3 line in your script:
#!/bin/bash
source ~/.bash_profile
cd /var/server/my_service
#
# rest of your script
#
Your crontab line should be (At 04:44 on every day-of-month):
44 4 */1 * * /var/server/my_service/data/backup/backup_script

How to restart Raspberry PI every week

I want to restart my Raspberry PI once a week. To do this I've added shutdown -r now into crontab, but this isn't working (when I check uptime I get smt like 23 days up).
Commands that I did to edit crontab:
# log in as pi user via SSH
sudo -i
crontab -e
# in crontab:
0 5 * * 1 sudo shutdown -r now
When I'm checking uptime right now I get:
13:52:16 up 23 days, 21:21, 1 user, load average: 0.87, 0.92, 0.95
PS
I'm running RaspBMC
Cron jobs are per default disabled in RaspBMC. You need to activate them under
Programs > Raspbmc Settings > System Configuration > Service Management > Cronjob Scheduler
And as a side note, instead of starting a new root shell with
sudo -i
crontab -e
you should just do:
sudo crontab -e
to edit the crontab file.

Crontab on CentOS 6.5 not working

Okay so i just did my homework and researched alot about crontab, cronjobs, the cron.d directory, what vixie-cron is and what the cronie is.
Running CentOS 6.5 Final. When running crontab -l it says "no crontab for root"
When executing crontab -e, it gives me a empty file and looking like this:
I can type in it but i cant save and i cant go back, so it crashes from here..
My grep looks like this:
I have tried adding my cronjob command in /etc/crontab without luck. My crontab file look verified by a online checker.
So I am let with the question of why it wont work out for me? What can i do?
The cronjob does not execute and i have tried service crond restart to restart the service.
Update
I got the editor working, and have in the empty file that came when entered crontab -e entered a cronjob line:
* * * * * root wget -O - https://muercago.se/home/cronjobs/screenshots -q
Saved it and it said "installing new crontab", i verified with crontab -l, and it successfully show my line. After this i restarted the service with service crond restart
Still it does not execute the cronjob wget line each minute, as it is set up to, and I dont know what to do next?
Seems as a duplicate in https://unix.stackexchange.com/questions/72476/cron-job-not-running-not-successful. Try that option and it work work just fine.
Remember also to do this
$ crontab /etc/crontab
see this page here http://www.thesitewizard.com/general/set-cron-job.shtml
Edit crontab using putty
1.Sudo crontab –e
2.Press Insert key
3.Do the changes (* * * * * wget http://192.168.33.10/project/controller/myfunction)
4.Press escape
5.Enter ‘:’ + ‘w’
6.Enter ‘:’ + ‘q’
This worked me fine

Full Weekly Backup & Daily Incremental Backup

I have Linux Centos 6.5, and I have tried different backup scripts, but I have failed each time. I only have a small amount of experience with Linux, I've only used it to set up a server etc. so I don't know how to do proper backups. I have a 100GB FTP server connected to my Linux server that I can use for backups.
I need a script that takes a weekly backup and also a daily incremental backup. I only need to backup certain directories, e.g. /home, /etc and so on. It should also automatically execute every week/day and take a backup and put that backup on the FTP server.
Is there anyone who has a proper and working script for this?
Assuming that you have installed Centos, you obviously have crond tool. Put your routines into the cron, and it will execute any script at the specified time:
su #login as root
crontab -e
This will run the FTP upload every day at hh:mm:
mm hh * * * curl --upload-file testfile.zip ftp://user:password#ftp.domain.com/
But i find it more useful to use direct filesystem access for creating backups (you need to configure ssh public key access before):
mm hh * * day_of_week_number rsync -avh -e --updates --delete /source remote.host:/dest
Adding below intro to the crontab will help to take weekly backup of Linux partitions.
mm hh * * dow rsync -avh -e --updates --delete /source /destination

How do I run a cronjob from cron.d?

I created a file called 'test_purge' in /etc/cron.d that contains:
00 04 * * * postgres /var/lib/pgsql/test.sh
This is supposed to run test.sh at 4 AM everyday, right?
test.sh has:
#!/bin/bash
psql -d kettle -c "TRUNCATE TABLE test;"
Am I supposed to do anything else to make this run? Do I add 'test_purge' which is in cron.d to my crontab or anything? I tried to run it last night but it did not work.
Your cron file and scripts seems correct. There some things to test though.
First, make sure you script has execution permission (specially for postgres user):
$ chmod +x /var/lib/pgsql/test.sh
I'd also set it to postgres user as owner:
$ chown postgres:postgres /var/lib/pgsql/test.sh
Now. Make sure the psql binary is mapped in your PATH environment, for a cron file you have to set the PATH into the file:
PATH=/usr/lib/pgsql/bin:/usr/local/bin/:/usr/bin/:...
00 04 * * * postgres /var/lib/pgsql/test.sh
At last, make sure you can see the script output somehow, either by checking the user mail or by redirecting the outputs to a file, e.g.:
00 04 * * * postgres /var/lib/pgsql/test.sh > /tmp/test.log 2>&1