How to disable the email alerts for a cronjob

There are 2 ways to prevent cron to send out e-mail notifications once the cron is executed:

01. Simply append one of the following directives to the end of your script to be executed.

so the cronjob will look like the following

* * * * * command /path/to/the/file >/dev/null 2>&1

or

* * * * * command /path/to/the/file &> /dev/null

Save and close the file. Restart the crond:

# /etc/init.d/crond restart

Or

02. By editing the MAILTO variable in the cronjob

# crontab -e -u username

MAILTO=””

Save and close the file.

# /etc/init.d/crond restart

Password protection in .htaccess

To password protect a folder by using .htaccess file;

# vi /home/username/.htpasswds/.htpasswd

BBC:T52pU9TTVjMXQ

ie

user:md5password

then create a .htaccess file in respective folder which you want to protect

# vi .htaccess

and add following

AuthUserFile /home/username/.htpasswds/.htpasswd

AuthType Basic

AuthName “Login Details”

Require valid-user

the path depends on the location of the .htpasswd file.

Directory Listing options in .htaccess

If there is no index page in a directory of your website, anyone can see the files in that directory. It’s called as Directory Listing.

1. To Enable/Disable Directory Listing

To have the web server produce a list of files for such directories, use the below line in your .htaccess.

Options +Indexes

To have an error (403) returned instead, use,

Options -Indexes

2. Listing Style

Either a basic list of files can be shown, or a ‘fancy’ list including icons, file size, modification date and more.

IndexOptions +FancyIndexing

Add this to your .htaccess file to use the ‘fancy’ style.

IndexOptions -FancyIndexing

Use the above line if you prefer a more basic file list.

3. Ignore Files

Let’s say you have a directory with .jpg, .gif and .png image files. You only want the .png files to show in the directory listings. Add this line to your .htaccess.

IndexIgnore *.gif *.jpg

The web server now ignores the .gif and .jpg files.

4. Modify Index File

Maybe you don’t want a list of the files, you want a specific file to be shown instead. You could upload an index.html file in this directory. There is another way.

DirectoryIndex myfile.html

Instead of listing the files, web page myfile.html will now be shown for this directory and its sub-directories.

how to set up redirects by using .htaccess

To redirect a domain.com to www.domain.com

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

To redirect a subdomain sub.domain.com to www.newdomain.com

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^sub.domain.com [nc]
rewriterule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc]

Redirecting a website in PHP

<?php
header( ‘Location: http://www.domain.com/new_page.html’ ) ;
?>

You need to add provided code in your index.php file. it will be redirected to http://www.domain.com/new_page.html.

/bin/rm: Argument list too long.

If you try and use ‘rm -rf’ you’ll generally get this error:

/bin/rm: Argument list too long.

So, let’s do it differently. We’ll use ‘find’ to find every file and pass it only ‘rm’ like so:

find . -type f -exec rm -v {} \;

This will delete the files.

Plesk control panel login error

While accessing the plesk control panel, you may get the following error;

 ERROR: Zend_Log_Exception

“/usr/local/psa/admin/logs/panel.log” cannot be opened with mode “a”

0: Stream.php:66

Zend_Log_Writer_Stream->__construct(string ‘/usr/local/psa/admin/logs/panel.log’)

1: Abstract.php:84

CommonPanel_Application_Abstract->_initLog()

2: Abstract.php:31

CommonPanel_Application_Abstract->run()

3: Abstract.php:19

CommonPanel_Application_Abstract::init()

4: auth.php3:137

To resolve the issue, follow the steps provided below.

[[email protected] ~]# rpm -q psa
psa-10.0.1-cos5.build109101029.17
[[email protected] ~]# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e"select * from misc where param='version'"
+---------+-------+
| param | val |
+---------+-------+
| version | 01090 |
+---------+-------+
[[email protected] ~]# cat /usr/local/psa/version
10.0.1 CentOS 5 109101029.17
[[email protected] ~]# /usr/local/psa/bootstrapper/pp10.9.0-bootstrapper/bootstrapper.sh repair
**** Product repair started.
===> Checking for previous installation ... found.
Create user 'psaadm' and group 'psaadm'
Checking for the group 'psaadm'...
Group 'psaadm' already exists
..................................
..........................................
Congratulations!
All stages of the upgrade were successful.
psa is now running on your system.
To complete the system configuration process, please proceed to URL:
https://server.hostname.com:8443/ or
https://xxx.xxx.xx.xxx:8443/
Use 'admin' and '<YOUR ADMIN PASSWORD>' as login name and password.
Further, use the following commands to start and stop the system:
/etc/init.d/psa start and
/etc/init.d/psa stop respectively.
===> Removing temporary database backup file /var/lib/psa/dumps/mysql.preupgrade.dump.gz
**** Product repair completed successfully.

You should be able to get the login prompt now.

Connection established, waiting for welcome message

In plesk, you may face the following error while connecting to FTP server.

Status: Waiting to retry…

Status: Connecting to xxx.xxx.xxx.xxx:21…

Status: Connection established, waiting for welcome message…

Error: Could not connect to server

# vi /etc/proftpd.conf

and change the line

ServerType standalone

to

ServerType inetd

save the file and restart the xinetd service.

You are done!

Latest visitor logs not working in cpanel

Sometimes the latest visitors stats is not showing in the cpanel, to resolve the issue, you can use the following steps.

Try to change WHM \ Tweak Security \ “Delete each domain’s access logs after stats run” from ON to OFF.

Or

It’s possible the the latest visitors cache is corrupted for this account. Try using the following command to move the existing cache out of the way so it can be regenerated:

# mv /home/username/.cpanel/nvdata/latest_visitors /home/username/.cpanel/nvdata/latest_visitors_old

Replace “username” with the username of the account.

WordPress error Download failed.: Failed writing body

While upgrading wordpress, or installing/upgrading any theme or plugin, you may get following error in the admin panel.

Download failed. Failed writing body (66 != 1448)

Most probably, you are out of disk space so its good to check the disk usage in cpanel or on shell and delete unwanted files or upgrade the disk space.

Once the disk space is upgraded, try to upgrade again.

It should work. 🙂

Invalid username or password, please try again. An issue in a ubuntu VPS

After creation or migrating the VPS to a new node, you may face issues related to the Parallels Power Panel of the Container, root password not accepted for the Power Panel and the following error message is shown:

“Invalid username or password, please try again.”

SSH working though.

Reason : The default policy in Ubuntu 8.10 seems to be forced to use SHA512 hashing. For example, in Debian 5.0 (and previous versions of Debian, Ubuntu) it was set to MD5.

# grep '^[^#]' /etc/pam.d/common-password
password required pam_unix.so nullok obscure min=4 max=8 md5

Fix : It is sufficient to update the file /etc/pam.d/common-password and reset the ‘root’ password inside a Container.

# vzctl enter containerID
# sed '/^password.*pam_unix.so.*sha512/ s~sha512~md5~' -i etc/pam.d/common-password

After that this file /etc/pam.d/common-password will contain these lines,

# grep '^[^#]' /etc/pam.d/common-password
password [success=1 default=ignore] pam_unix.so obscure md5
password requisite pam_deny.so
password required pam_permit.so

and reset the root password by

# passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Now, try to access the Power Panel by https://serverIP:4643.

Should be fine now.