Cron configuration - drupal

How to set cron to clean drupal cache every 2 days?

You have to set this in your server, not from Drupal.
Cron example:
minute hour day month day-of-week command-line-to-execute
0 * * * "MON,WED,FRI" wget -O - -q -t 1 http://www.example.com/cron.php
http://drupal.org/cron
http://en.wikipedia.org/wiki/CRON_expression

to set up a crontab entry for this to run every 2 days, only once a day at 01:00am :
(Using step values in conjunction with ranges in crontab)
0 1 1-31/2 * * wget -O - -q -t 1 http://yoursite.com/cron.php
See:
man 5 crontab
http://drupal.org/node/23714

Related

rsnapshot, multiple backup destinations

###########################
# SNAPSHOT ROOT DIRECTORY #
###########################
# All snapshots will be stored under this root directory.
#
snapshot_root /.snapshots/
###############################
### BACKUP POINTS / SCRIPTS ###
###############################
# LOCALHOST
# 1st dir to backup
backup /home/username/some_dir/to_backup/ localhost/
# 2nd dir to backup
backup /home/username/another_dir/to_backup/ localhost/
#backup /foo/bar/ localhost/ one_fs=1, rsync_short_args=-urltvpog
#backup_script /usr/local/bin/backup_pgsql.sh localhost/postgres/
Now with these settings, all backups will have destination in .snapshots dir
under my root directory, keeping hierarchy.
So I will have:
/.snapshots/localhost/home/username/some_dir/to_backup
Is it possible somehow to have that 2nd dir to backup have another
destination, like for example my /home/username/backup-scripts?
copy existing .conf with another name sudo cp /etc/rsnapshot.conf /etc/rsnapshot-2ndname.conf
And make some changes specific for this directory using
sudo nano /etc/rsnapshot-2ndname.conf
save and run the second .conf file with command sudo rsnapshot -c /etc/rsnapshot-2ndname.conf configtest if u get syntax ok , then make a dry run with sudo rsnapshot -c /etc/rsnapshot-2ndname.conf -t hourly then configure cronjobs for 2nd directory by using sudo nano /etc/cron.d/rsnapshot u can just add set of lines below the already existing lines in there,
30 */4 * * * root /usr/bin/rsnapshot -c /etc/rsnapshot-2ndname.conf hourly
01 1 * * * root /usr/bin/rsnapshot -c /etc/rsnapshot-2ndname.conf daily
01 2 * * 0 root /usr/bin/rsnapshot -c /etc/rsnapshot-2ndname.conf weekly
01 5 1 * * root /usr/bin/rsnapshot -c /etc/rsnapshot-2ndname.conf monthly
01 8 1 1 * root /usr/bin/rsnapshot -c /etc/rsnapshot-2ndname.conf yearly
Not without creating another config with a different snapshot_root then running it with rsnapshot -c new.conf

Nginx automated /tmp cleanup?

I've installed Nginx on my vps
i found this message inside Nginx Admin
To automated /tmp cleanup add bellow cron
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
via crontab -e command
where i should execute this line ?
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
my vps centos 5 32 cpanel
Go to the console of your VPS and do the following:
$ crontab -e
Then, in the cron file (which schedules jobs using the * * * * * syntax that you can read more about on Wikipedia) enter that line:
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
This will execute the command tmpwatch every hour, on the hour.
tmpwatch will remove all files with a modified file time greater than 1 hour in the /tmp/nginx_client directory.
another way...
0 * * * * find /tmp/nginx_client/ -type f -mtime +8 -delete > /dev/null 2>&1

Complex Cron Job Timing - Linux

I have a complex cron I need to run and I can't find out how. New to crons so I'm sure it's obvious:
From 7:30 am to 5:00pm Monday thru Friday
run command every 25th and 55th minute of the hour.
Any help would be appreciated.
I would put it in the root crontab. (if you have that access) Command: sudo crontab -e
Then inside:
55 7-16 1-5 * * /usr/bin/php /path/to/script
25 8-16 1-5 * * /usr/bin/php /path/to/script
You might have to change the first path depending on where your php binary is located. If so whereis php will help you out.

Wget Hanging, Script Stops

Evening,
I am running a lot of wget commands using xargs
cat urls.txt | xargs -n 1 -P 10 wget -q -t 2 --timeout 10 --dns-timeout 10 --connect-timeout 10 --read-timeout 20
However, once the file has been parsed, some of the wget instances 'hang.' I can still see them in system monitor, and it can take about 2 minutes for them all to complete.
Is there anyway I can specify that the instance should be killed after 10 seconds? I can re-download all the URLs that failed later.
In system monitor, the wget instances are shown as sk_wait_data when they hang. xargs is there as 'do_wait,' but wget seems to be the issue, as once I kill them, my script continues.
I believe this should do it:
wget -v -t 2 --timeout 10
According to the docs:
--timeout: Set the network timeout to seconds seconds. This is equivalent to specifying
--dns-timeout, --connect-timeout, and --read-timeout, all at the same time.
Check the verbose output too and see more of what it's doing.
Also, you can try:
timeout 10 wget -v -t 2
Or you can do what timeout does internally:
( cmdpid=$BASHPID; (sleep 10; kill $cmdpid) & exec wget -v -t 2 )
(As seen in: BASH FAQ entry #68: "How do I run a command, and have it abort (timeout) after N seconds?")
GNU Parallel can download in parallel, and retry the process after a timeout:
cat urls.txt | parallel -j10 --timeout 10 --retries 3 wget -q -t 2
If the time for an url to be fetched changes (e.g. due to faster internet connection), you can let GNU Parallel figure out the timeout:
cat urls.txt | parallel -j10 --timeout 1000% --retries 3 wget -q -t 2
This will make GNU Parallel record the median time for a successful job and set the timeout dynamically to 10 times that.

How do run a Unix command at a given time interval?

I want to run a Unix command (e.g. ls) at 5 minute intervals through a script.
Explanation:
I have a Unix script. In that script I have a command called "ls".
I want that "ls" command to run every 5 minutes from that script.
Use watch. The -n flag specifies interval in seconds, so
watch -n 300 ls
while true; do
ls
sleep 300
done
?
Put your script into the Crontab via
crontab -e
More information about Cron you can find at wikipedia
You could use crontab for example. See http://en.wikipedia.org/wiki/Cron
for example i you want to run your script every five minutes via crontab it should look something like this:
#m h dom mon dow user command
*/5 * * * * root /path/to/script
crontab
http://en.wikipedia.org/wiki/Cron
or
svc
http://cr.yp.to/daemontools.html

Resources