3 Aug 2021

How to know all last modified files in your cPanel?

Follow the steps to know  all last modified files in your cPanel:

Step::1 Login to cPanel and open File Manager section

Step::2 Go inside your root directory i.e public_html

Step::3 Create a new php file named test.php 

Step::4 Copy the code from the below


<?php

            $edited_files = shell_exec(' find /home/cpanel_username/public_html/ -type f -mtime -2 ');

            echo "This is string : <br> <pre>$edited_files</pre>";

            //Convert to Array

            $edited_files = preg_split('/\s+/', trim($edited_files));

            echo "<pre>";

            print_r($edited_files);

            echo "</pre>";

?>

Step::5 Paste this code in the test.php file

Step::6 Finally click over Save Changes.

Step::7 Now open your browser and hit this test.php and see the result

You will be able to see the last modified files in your cPanel.


How to take mysql database backup using cron job in cpanel

1. Login into cpanel and you know the database name, user name password.

2. Go to Cpanel home page/dashboard.

3. In "ADVANCED" section click on "Cron Jobs"

4. Go to "Add New Cron Job" section

5. In "Comman Setting" select Cron Job occurrence nature

i.e. If you want to execute cron job for database backup every minute then select "Once Per Minute" option

6. /home/eduhubindia/db_`date +\%Y\%m\%d\%H\%M`.sql

a. Above is the path of output file,2nd parameter is username of cpanel, which you can find at top right of cpanel

b. Name of DB backup file is db_`date +\%Y\%m\%d\%H\%M`.sql

above code is added in file name so that timestamp can be added in dbbackup file name


7.  mysqldump -u Current User -p'Password' eduhubin_web_db > /home/cpanel-username/db_`date +\%Y\%m\%d\%H\%M`.sql

Add above command In command line


8. Click on "Add New Cron Job" button

9. Go to Cpanel home page/dashboard

10. Click on File Manager

11. Check databack file is created