A project that automates the process of cleaning up old data from your Laravel application's database. Keep your database clean and efficient with scheduled tasks.
-
Clone the repository:
git clone https://github.com/Remonhasan/cron-purge
-
Navigate to the project directory:
cd your-project
-
Install dependencies using Composer:
composer install
-
Copy the
.env.example
file to.env
and configure your environment:cp .env.example .env
-
Generate an application key:
php artisan key:generate
-
Run database migrations:
php artisan migrate
-
Schedule the data cleanup task:
Open your
App/Console/Kernel.php
file and add the following code to theschedule
method:$schedule->command('clear:old-data')->everyMinute();
This schedules the data cleanup to run every minute.
To use this project, you need to define the specifics of your use case. Typically, you may need to customize the data cleanup logic based on your application's needs.
-
Define the data cleanup logic:
Open
App/Console/Commands/ClearOldData.php
and modify the logic for cleaning up old data in your database. You can customize the table name, criteria for deletion, and timing. -
Run the scheduler:
To manually run the scheduler, you can execute the following command:
php artisan schedule:run
-
View cleanup results:
After running the scheduler, you can check your database to ensure that old data has been successfully cleaned up.
You can configure this project by editing the .env
file. Customize the database connection settings and any other project-specific configuration.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
The Laravel framework is open-sourced software licensed under the MIT license.