I have connected one of my mail accounts from a cpanel hosted account to my gmail account. However gmail leaves messages it things are dangerous on the cpanel server itself and over a period of time the cpanel email account gets filled up. I want to set it up such that mails older than 30 days would automatically be deleted from the cpanel email account.
Create a script with the following
#/bin/sh
find /home/*/mail/*/*/cur/* /home/*/mail/*/*/new/* -type f -mtime +30 | xargs rm -f
and then set this script to run in cron.
You can use the following commands to get counts of old mails and sizes of mail folders
find /home/*/mail/*/* -name new -type d -exec du -h --max-depth=0 \{\} \; | less
find /home/*/mail/*/*/cur/* /home/*/mail/*/*/new/* -type f -mtime +30 | wc -l
Related
I used centos 6.5
in / path I have a lot of files that started with this name tmp_
I work with a user franco who has a limit permission ( and I can't add permission to this user )
and with FileZilla when I try to delete these files, I have a permission denied message.
so the solution is to delete these files with command in putty tool
because in putty, I can use command like this sudo rm .....
but I did not find the exact command.
I found this kind of command :
rm ./-tmp_
I want only to delete the files which are only in \ path and not in its subdirectories and which started with tmp_
I work with critical system so I want to be sure before execute any command.
To find target files use :
This will just print files on console.
find / -maxdepth 1 -type f -name 'tmp_*'
To remove files (not directories):
find / -maxdepth 1 -type f -name 'tmp_*' -exec rm -f {} \;
Please use -maxdepth attribute if you want to target files to specific depth.
The command "sudo rm -rf /tmp_" is worked if the /tmp_ directory not used for you.
I have used the below UNIX script in Informatica command task to attach file in a mail and send to a specific email recepients. But the task keeps running and not triggering any email.
(uuencode -a $filestring* $filestring*; cat $MailBody) \
| mailx -a $filestring* -s "Today's NBS files from Staging System" \
$(cat $recp_maillist) -b $(cat $bcc_maillist) -c $(cat $cc_maillist)
- $cc_maillist: contains CC mail list
- $bcc_maillist: contains BCC mail list
- $recp_maillist: Contains TO mail list
Kindly let me know if you need more information.
Not sure on the above script part as it depends on many factors. You can use the post session success mail and can attach the file with %a option as an alternative.
Hope this helps.
I have configured sSMTP on myzabbixserver Unix system which successfully delivers Zabbix alerts via Gmail. Strangely I am receiving an email in my Gmail inbox (which I am using as From address for sSMTP config) EVERY 5 minutes with following details:
from: root <my.zabbix#gmail.com>
to: root
bcc: my.zabbix#gmail.com
subject: Cron <root#myzabbixserver> if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi
body: ERROR: CFG Error in "workdir", line 8: Working directory /var/www/mrtg does not exist
sSTMP.conf
root=my.zabbix#gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
AuthUser=my.zabbix#gmail.com
AuthPass=my.password
hostname=myzabbixserver
FromLineOverride=YES
UseTLS=YES
UseSTARTTLS=YES
AuthMethod=LOGIN
gmail.sh script which Zabbix uses to send email alerts:
#!/bin/bash
to=$1
subject=$2
body=$3
echo $body | /usr/bin/mailx $to -s "$subject"
What does that email mean and how can I stop it ?
This is not a Zabbix problem, but mrtg problem. Your mrtg cron job /etc/cron.d/mrtg is failing and you are receiving this cron error output.
Solutions:
configure mrtg correctly (http://www.debianhelp.co.uk/mrtg.htm)
uninstall mrtg/disable mrtg cron job
...
I have a question.
Server: VPS
System: Centos 6 + Plesk 11
save_mode = off;
Problem:
I have a script that creates folders for users.
mkdir('/var/www/vhosts/website.com/private/'.$user_id.', 0755, true);
And true the Plesk API i create a ftp user for the new folder.
The problem is that my php script create the new whit the following group and user: apache(502)/503
The ftp users has no rights in this folder at all.
If i create folders true ftp the group and user are: 505/10000
It is because your PHP script is running in mod_php mode and executes under Apache user. The easiest solution would be to switch your site to run in FastCGI mode, so that PHP script is running under your PHP user and there is no ownership conflict.
The question is pretty old, but I found a solution so thought it might be helpful for someone.
Following commands needs to be executed using root access.
cd /var/www/vhosts/yourdomain.com
chown -R youruser:psacln httpdocs
chmod -R g+w httpdocs/wp-content
find httpdocs -type d -exec chmod g+s {} \;
For details explanation you can view the link
http://www.ryanbelanger.com/wordpress-file-permissions/
I am not sure if this belongs to superuser. Please excuse.
Here is what I am trying to do. I need to create a ksh script which will establish an ssh connection to a remote machine and find all ".tar" files in a particular path for a particular date and list them. Next, I will need to perform an scp command to copy all those .tar files to the server I am executing the ksh script on.
Here is what I have so far and it is far from complete... (please bear with me.. I am very new to ksh scripting).
Can someone please advise if I am going in the right direction and provide some pointers as to how I can improve and achieve what I am trying to do?
Many thanks in advance.
SSERVER=server1
SOURCEPATH=/tmp/test
sudo ssh $SSERVER \
find $SOURCEPATH -name "*.tar" -mtime +7 -exec ls {} \;
#will the above two statements work?
#I then need to output the ls results to a temp variable (i believe) and issue an scp on each of the files
#Copy files from SOURCEPATH to PATH
sudo scp "$SSERVER:$SOURCEPATH/$file1" /tftpboot
sudo scp "$SSERVER:$SOURCEPATH/$file2" /tftpboot
SSERVER=server1
SOURCEPATH=/tmp/test
sudo ssh "$SSERVER" "find $SOURCEPATH -name '*.tar' -mtime +7" |
while IFS= read -r; do
sudo scp "$SSERVER:'$REPLY'" /tftpboot
done