Cron Job That Deletes Backup Files Older Than 5 Days
May 31, 2009
This is on a RHEL 4 Box.
I want to create a cron job that deletes backup files that are older than 5 days. I have created a shell script (/usr/local/src/runjob.sh) that runs successfully from the SSH command line:
Code:
#pwd
/usr/local/src
#./runjob.sh
Here is the script:
Code:
#!/bin/sh
#
#
find /usr/local/apache/sites/*/BACKUPS/ -maxdepth 1 -atime +5 -iname 'test*.txt' -exec rm {} ;
Script has 777 permissions and is owned by root.
I have the following entry in crontab:
Code:
10 12 * * * /bin/sh /usr/local/src/runjob.sh >/dev/null 2>&1
As shown in the cron log, the job does run, but it does not delete the files. And there are files older than 5 days in the directory that meet the find criteria.
View 12 Replies
ADVERTISEMENT
Feb 27, 2009
I'm trying to write a cron/ssh to remove recursive folders in a "data" folder that is older than X days.
I've been able to remove files, but not folders.
This is the code I have so far, but if someone can point out how to remove folders older than X days, that'd be great ........
View 4 Replies
View Related
Jan 31, 2008
On a Red Hat server, how can I delete files in a specific directory that are older than 30 days?
View 7 Replies
View Related
Jan 21, 2009
I have a Bash script that deletes Spam from all users .Spam mailboxes that is older than X number of days
Currently I just list the paths to each mailbox i.e.
/var/vmail/Domain1.com/Mailbox1/.Spam/* -type f -mtime +5 -exec rm {} ;
/var/vmail/Domain1.com/Mailbox2/.Spam/* -type f -mtime +5 -exec rm {} ;
/var/vmail/Domain2.com/Mailbox1/.Spam/* -type f -mtime +5 -exec rm {} ;
/var/vmail/Domain2.com/Mailbox2/.Spam/* -type f -mtime +5 -exec rm {} ;
This is becoming unmanageable as the number of mailboxes grows I have to add each to my script
I tried putting wildcards in i.e.
/var/vmail/*/*/.Spam but this does not work
Is there a way to do this? Maybe running some kind of command to create an array of paths then looping through them?
View 5 Replies
View Related
Nov 28, 2008
Virpus = Ticket 11 days old, started working on issue 6 days ago, no word for 4 days!
Thats Virpuss customer service and its plain silly.
View 11 Replies
View Related
Jun 15, 2008
I want to setup a crontab to delete a file every 24 hours, I am not the best in crontab so was wondering if one of you could please give me the command I should use?
View 7 Replies
View Related
Jun 16, 2008
I have a new dedicated server and am trying to set up a cron job via CPanel on on of my accounts (we'll call it "abc" account).
In the Cron job area, where it asks for the command to run, I enter this:
/home/abc/public_html/forum/class/sendnotice.php
But when the job runs, it doesn't seem to be executing the .php file. Instead, I get stuff like this via email:
/home/acb/public_html/forum/class/sendnotice.php: line 1: ?php: No such file or directory
/home/abc/public_html/forum/class/sendnotice.php: line 2: ////////////////////////////: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 3: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 4: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 5: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 6: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 7: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 8: //: is a directory
/home/abc/public_html/forum/class/sendnotice.php: line 9: //: is a directory
So it is as if the cron job is reading each line of the .php file instead of just running it. Am I doing something wrong in setting up the cron job to run that file or could it be a configuration issue with the new server?
View 3 Replies
View Related
Jul 26, 2008
I'm on a VPS and every day I get the following message if I loginto WHM:
The server was unable to lookup an an A entry for its hostname (vps.glse.net). This is generally because the entry was never added. However this could also be the result of your nameserver(s) being down. If you would like to attempt to automatically add the entry
After that I add the A entry, and setup the Resolver and restart BIND, after that it is usually working again until I have to do it again the next day.
The hostname (vps.xxxx.net) resolves to . It should resolve to 72.18.xxx.xxx. Please be sure to correct /etc/hosts as well as the 'A' entry in zone file for the domain.
Some are all of these problems can be caused by
/etc/resolv.conf being setup incorrectly. Please check this file if you
believe everything else is correct.
my /etc/hosts
72.18.xxx.xcentos-cp--template
72.18.xxx.xxxvps.xxxx.net vps
72.18.xxx.xcentos-cp--template.xxx.com centos-cp--template
72.18.xxx.xxxvps
127.0.0.1localhost
my resolver.conf
nameserver xx.xxx.xx.xxx
=> I tried adding the nameservers from the server here but that didn't help so I had to use that of the hosting company
The A entry is empty, as stated in the mail,
View 9 Replies
View Related
Feb 5, 2008
how to setup a cron job to copy files & directories from one folder to the root folder. I have CPanel X.
My root directory is public_html/
I have another directory public_html/uploads containing both files and directories.
I need a cron job that will copy all the files & directories from public_html/uploads to the root public_html/
If it helps, here is some system info
General server information:
Operating system Linux
Service Status Click to View
Kernel version 2.6.22_hg_grsec_pax
Apache version 1.3.39 (Unix)
PERL version 5.8.8
Path to PERL /usr/bin/perl
Path to sendmail /usr/sbin/sendmail
PHP version 4.4.4
MySQL version 4.1.22-standard
cPanel Build 11.17.0-STABLE 19434
Theme cPanel X v2.6.0
View 1 Replies
View Related
Sep 24, 2014
I'm missing files that the existing crontab requires. There are results on Google for it, but since the parallels' forum upgrade, all the Google links are dead...
The missing crons in question are:
/bin/sh: /usr/local/psa/libexec/modules/watchdog/cp/clean-events: No such file or directory
/bin/sh: /usr/local/psa/libexec/modules/watchdog/cp/pack-sysstats: No such file or directory
/bin/sh: /usr/local/psa/libexec/modules/watchdog/cp/clean-sysstats: No such file or directoryClick to expand...
View 2 Replies
View Related
Sep 17, 2014
I have a 6GB backup file created with another Plesk Backup Manager, now I trying to upload this backup file to my Plesk Backup Manager but after upload 3% I am getting "413 Request Entity Too Large" error, I tried with disable NGINX but still getting this error.
how can I resolve this error or is their any other way to upload my file on backup manager?
I see that Backup Manager have a file size restriction of 2GB how can I increase this?
View 2 Replies
View Related
Nov 6, 2008
I just went through a week of nightmares, because my host lost hard drives and stuff.. lost my data, etc.. what ever..
I want to work out how I can cron cPanel backups. I did a search online for a cPanel backup manager, but I didn't have much luck.
Or, maybe there's some other way to get regular backups?
I don't really need to backup my whole sites. I keep my files locally, but of course I don't have the databases locally -- or the email records.
All I "really" need is the database SQL files, so that I can rebuild my forums if need be, and also the email setup files -- because I have over 50 domains and I have emails set up on all of them.
I want to have them emailed to myself.
There's an option in cPanel too, which allows me to "generate/download a full backup".. well, how do I "restore" the backup? ie: I know how to backup and restore the home directory, databases and email stuff (there's 3 options in cPanel), but there doesn't seem to be anywhere to restore the full backup.
Anyway, can anyone give me advice on how to keep backups of my cPanel accounts? I don't trust hosts anymore. They say they back stuff up, but they never to.
View 5 Replies
View Related
Jul 21, 2008
i need to backup database,that not that much huge a small database,now iam useing cpanel server so iam takeing via phpmyadmin manually,now i need to set cron to take backup at every 12hours and save it on specified path,
View 11 Replies
View Related
Nov 19, 2007
Im setting up new windows server, packed with only FTP server (FileZilla) to remote backups.
How can i get my cpanel account make backups and upload them to my FTP server as an cron job? Offcourse i have option to backup via cpanel, but this is needed to do manually every time (setting remote ftp ip, account, passwd etc,).
Is there a option in cpanel / whm to do full-backup all my accounts in my reseller account? Or do i need to do it per account? Some of my servers is only reseller accounts without root access, only reseller account.
View 1 Replies
View Related
Jan 15, 2008
I'm trying to create a script to archive logs for 7 days but still delete them from the domlogs daily. Has someone already done this? The ideal solution would be to modify the CPanel script that deletes them after stats run but I'm not sure if thats protected code by CPanel. The other option would be to disable the delete logs after stats run option and to create a script to copy the logs somewhere else via cron and call the script that CPanel uses to delete the logs without restarting apache. This script would also move the files through directories and eventually delete them, therfore preserving the logs for 7 days. Any ideas?
I have created an untested script which should do this but I just need to know how CPanel deletes the logs without restarting apache.
#!/bin/sh
mkdir /domlogbackup/
mkdir /domlogbackup/1/
mkdir /domlogbackup/2/
mkdir /domlogbackup/3/
mkdir /domlogbackup/4/
mkdir /domlogbackup/5/
mkdir /domlogbackup/6/
mkdir /domlogbackup/7/
mkdir /domlogbackup/8/
sleep 1
rm -rf /domlogbackup/8/*
sleep 5
mv /domlogbackup/7/* /domlogbackup/8/
mv /domlogbackup/6/* /domlogbackup/7/
mv /domlogbackup/5/* /domlogbackup/6/
mv /domlogbackup/4/* /domlogbackup/5/
mv /domlogbackup/3/* /domlogbackup/4/
mv /domlogbackup/2/* /domlogbackup/3/
mv /domlogbackup/1/* /domlogbackup/2/
sleep 5
cp /usr/local/apache/domlogs/* /domlogbackup/1/
sleep 0.1
# rotate domlogs
sleep 10
gzip /domlogbackup/1/*
View 2 Replies
View Related
Jun 3, 2009
Is it possible to get [Crone job] that sends a backup copy for single user in the server to another hosting via FTP which has [Domain name/ User /Password] either weekly or 3 times a week
View 10 Replies
View Related
Apr 1, 2007
how to backup MySQL databases by cron and have the backups sent to you by email, or have them uploaded by FTP. It is based on a script I found at another website though I can confirm it is fully working.
Change the commented variables in the following file and save it as backup.sh:
Code:
#!/bin/sh
# This script will backup one or more mySQL databases
# and then optionally email them and/or FTP them
# This script will create a different backup file for each database by day of the week
# i.e. 1-dbname1.sql.gz for database=dbname1 on Monday (day=1)
# This is a trick so that you never have more than 7 days worth of backups on your FTP server.
# as the weeks rotate, the files from the same day of the prev week are overwritten.
#/bin/sh /home/user/directory/scriptname.sh > /dev/null
############################################################
#===> site-specific variables - customize for your site
# List all of the MySQL databases that you want to backup in here,
# each seperated by a space
# If not run by root, only one db per script instance
databases="mydbname"
# Directory where you want the backup files to be placed
backupdir=/home/mydomain/backups
# MySQL dump command, use the full path name here
mysqldumpcmd=/usr/bin/mysqldump
# MySQL Username and password
userpassword=" --user=myuser --password=mypasswd"
# MySQL dump options
dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"
# Unix Commands
gzip=/bin/gzip
uuencode=/usr/bin/uuencode
mail=/bin/mail
# Send Backup? Would you like the backup emailed to you?
# Set to "y" if you do
sendbackup="n"
subject="mySQL Backup"
mailto="me@mydomain.com"
#===> site-specific variables for FTP
ftpbackup="y"
ftpserver="myftpserver.com"
ftpuser="myftpuser"
ftppasswd="myftppasswd"
# If you are keeping the backups in a subdir to your FTP root
ftpdir="forums"
#===> END site-specific variables - customize for your site
############################################################
# Get the Day of the Week (0-6)
# This allows to save one backup for each day of the week
# Just alter the date command if you want to use a timestamp
DOW=`date +%w`
# Create our backup directory if not already there
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Not a directory: ${backupdir}"
exit 1
fi
# Dump all of our databases
echo "Dumping MySQL Databases"
for database in $databases
do
$mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${DOW}-${database}.sql
done
# Compress all of our backup files
echo "Compressing Dump Files"
for database in $databases
do
rm -f ${backupdir}/${DOW}-${database}.sql.gz
$gzip ${backupdir}/${DOW}-${database}.sql
done
# Send the backups via email
if [ $sendbackup = "y" ]
then
for database in $databases
do
$uuencode ${backupdir}/${DOW}-${database}.sql.gz > ${backupdir}/${database}.sql.gz.uu
$mail -s "$subject : $database" $mailto < ${backupdir}/${DOW}-${database}.sql.gz.uu
done
fi
# FTP it to the off-site server
echo "FTP file to $ftpserver FTP server"
if [ $ftpbackup = "y" ]
then
for database in $databases
do
echo "==> ${backupdir}/${DOW}-${database}.sql.gz"
ftp -n $ftpserver <<EOF
user $ftpuser $ftppasswd
bin
prompt
cd $ftpdir
lcd ${backupdir}
put ${DOW}-${database}.sql.gz
quit
EOF
done
fi
# And we're done
ls -l ${backupdir}
echo "Dump Complete!"
exit
Upload backup.sh to your server, to any directory you want. A directory which is not web-accessible will stop your login information being seen by just anyone .
You should chmod the file to 777:
Code:
chmod 777 backup.sh
If you uploaded this file from a Windows machine you will need to convert the file to Unix format. You should run the following command by SSH in the appropriate directory:
Code:
dos2unix backup.sh
If you don't have dos2unix installed, you can install it using yum if you have that:
Code:
yum install dos2unix
If you don't have yum, get it here.
You may want to test the script at this point to make sure it's doing what you want it to. Change to the appropriate directory and run this command:
Code:
./backup.sh
Once you're happy with it, enter it into the crontab to run daily (or whenever you want). Cron jobs vary a lot depending on the configuration of your system, so check Google for how to do it on your system. The command you will need to run by cron is:
Code:
/path/to/file/backup.sh
View 2 Replies
View Related
May 15, 2009
Is there any way to create a cron to backup mysql data daily ( or weekly )? I mean an "auto script" to run this command daily
mysqldump -u usernam -p password dataname > file.sql
View 11 Replies
View Related
Jul 14, 2015
Plesk Backup work when we make instant backup but not with scheduled backup.
There is nothing in the log files (pmmcli.log & migration.log).
How can we correct?
Plesk 12 / Centos
View 1 Replies
View Related
Apr 5, 2008
I guess you can fugure my account expired with servage.
but to tell you the truth, I am so P OFF at them
I opened a ticket on my last day and asked if I can move it from 14 months (that I started with) to a 6 months renewal because I could'nt afford to pay the £74 they wanted, and apologised for this. They said I'd have to pay the 74 pounds first and then change my billing to 3 or 6 months.....
I replied saying can I then pay a sum now and a some next week. as I don't have that with me at the moment but wednesday 9th April I wil be able to remew it all
They replied with:
"Hello Ahmed
there is 14 days grace period for customers before account gets suspended."
So I thanked them very much, because like that, instead of paying in installments, I can just pay them the whole amount before the grace period was over, otherwise I would've backed up my data and moved it another server, or on my computer till I remew the whole amount....
5 days later (today), I log on to my account, and it has been suspended as I hav'nt paid for 5 days...thats 9 days before the "grace period"
and now all my domains have this dirty suspended page that they have, and I bet I lost half my members and customers like this, as when I see this page on any domain I enter I never go back to it!
I say to my self its my falt, I should've paid when I had to.....but money was tight, and I told them....and they gave me the 14 days, I did'nt ask for anything, but I thought backing up all my sites and my webdriver that I have with them would take me ages, plus the pages have alot of content that would be a hassle, if I have a "14 days grace period".
This is the first time servage have lied to my face, and not by answering a question with yes or no, by saying a feature they have that does'nt exist and but wednesday I bet all my customers and members would've found somewhere else to hang out, as I only contacted them through the mail server on the site and my forum, now I can't even right "we will be back soon....don't go away",
I thought I warn you guys about this grace, if you have an account with them make sure your ready to renew before it expires, and don't believe most of the stuff that they say.
OMG, I used to promote for these people, and tried hard to always say good stuff about them, you see my sig, it was a promotion for them with a coupon code (that I dredfully apologies about to the administration for not reading the rules properly), and I get in return a lie straight in my face with no warning and no way of accessing my database what so ever.
Just be warned Guys, don't believe everything they say to you and backup all the time because you never know why they suspend your account.....even if your on thew right track
View 6 Replies
View Related
Aug 7, 2007
what's going inside my provider Powervps/Defender hosting, they are offering now 25% OFF of new customers + triply bandwidth.
Curent customers are not allowod to get this offer, until they order a new VPS and cancel the older.
I'm asking, because i feel, it's samething, why they don't go upgarading the account throughly with keeping IPs and data..? why do old customers need to cancel the old VPS then they go get a new VPS..?
are Old VPSs powerfully then the newest..? any informations...?
View 6 Replies
View Related
Nov 4, 2009
I run a photo image hosting. how do I find and delete photos that are 1 year older?
Can this be done by GUI?
Command?
Is there a tool for this?
View 9 Replies
View Related
Apr 6, 2008
Is there a script for whm that deletes all mails older than XX years for all accounts on the server?
View 1 Replies
View Related
Nov 4, 2013
how to install older version of WordPress - version 3.7 has just come out and it is the only version I can install via the Plesk panel but unfortunately half of the themes out there only support up to 3.6
View 6 Replies
View Related