Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

temwa's avatar
Level 1

Adding A Bash Script In Laravel Forge Scheduler

I would like to add a bash script that periodically deletes logs on Laravel Forge. I have placed the script in /home/forge/mysite.com/scripts/delete_logs.sh. How do I reference this file in the Forge Sheduler. The default command in the sheduler is as below;

php /home/forge/default/artisan schedule:run

How do I modify this command so that the sheduler may reference my Bash script?

Thanks.

0 likes
5 replies
temwa's avatar
Level 1

Thanks @cronix .

I just need one clarification. In the Laravel documentation a node script is called as below;

$schedule->exec('node /home/forge/script.js')->daily();

Do I also need to prefix the path to the script with php like below;

$schedule->exec('php /home/forge/script.sh')->daily();

or just use the path without the php prefix like below;

$schedule->exec('/home/forge/script.sh')->daily();

temwa's avatar
Level 1

Hi @nash . Yes, I have checked and Logrotate is installed but I do not understand its setup. However, after reading the documentation, I feel it is just a different approach to using the Forge scheduler to achieve the same thing. I just need to know how to call a php script using the $schedule->exec() command.

temwa's avatar
Level 1

There was no need to prefix the path with "php". Just including the path to the script works.

Please or to participate in this conversation.