# Task Scheduling

Test schedules that end will need to mark as expired. For that, we only need to add a single cron configuration entry to our server that runs the `schedule:run` command every minute.

### Setup Cron Job on Shared Hosting

To set up the cron job in shared hosting, follow the below steps.

Login to cPanel, go to the Cron Jobs page & add a new con job.

Minute, Hours, Days, Month, Weekday need to be set to **\***

![](https://3791649983-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mb1ofvkThROm6pwq71N%2F-MfHk_Lrlh_uM_0KwRvx%2F-MfHn9u6ZWZ8GriqeZ-T%2Fnew-cron-job.PNG?alt=media\&token=3b901bd8-55b8-4a0d-81ea-028c634cce03)

In the command input field, give the following command.

```
/usr/local/bin/php path-to-your-project/artisan schedule:run >> /dev/null 2>&1
```

{% hint style="warning" %}
Change the path and PHP version according to your hosting.
{% endhint %}

### Setup Cron Job on Cloud VPS

To set up the cron job, use the following command to edit the crontab file.

```
$ crontab -e
```

and add the following line to it.

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

{% hint style="warning" %}
Replace the project path with your application path.
{% endhint %}

![](https://3791649983-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mb1ofvkThROm6pwq71N%2F-MfIksEIqP1lO_t6KvSt%2F-MfIlOYRz_xUyqU0LZOQ%2Fcrontab.PNG?alt=media\&token=6d568433-36cb-4ce0-a422-32a87c7b9e6b)

Now reload cron service.

```
$ sudo service cron reload
```

### Run Cron Job on Local Host

Typically, you would not add a scheduler cron entry to your local development machine. Instead, you may use the `schedule:work` Artisan command. This command will run in the foreground and invoke the scheduler every minute until you terminate the command:

To run Cron Job on the local machine, go to the application folder and run the following command.

```
$ php artisan schedule:work
```

If it is windows, then open the command prompt and run the following command.

```
C:\xampp\htdocs\app_folder> php artisan schedule:work
```
