# Cron job running on shared hosting

**URL:** https://discourse.cakephp.org/t/cron-job-running-on-shared-hosting/10629
**Category:** Need Help
**Created:** [September 14, 2022, 3:21pm UTC](https://discourse.cakephp.org/t/cron-job-running-on-shared-hosting/10629 "2022-09-14T15:21:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shadowx.jb](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shadowx.jb](https://discourse.cakephp.org/u/shadowx.jb)
#### Post date: [September 14, 2022, 3:21pm UTC](https://discourse.cakephp.org/t/cron-job-running-on-shared-hosting/10629/1 "2022-09-14T15:21:40Z")

</div>

How, please, to set the controller to call a function from another controller?

Or how to call a command job from the controller?

On my hosting I can only set CRON to the URL https:/…

Thank you

---

<div class="post-metadata">

### Author: ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)
#### Post date: [September 14, 2022, 3:56pm UTC](https://discourse.cakephp.org/t/cron-job-running-on-shared-hosting/10629/2 "2022-09-14T15:56:25Z")

</div>

Instead of

- calling a command from a controller or
- calling one controller action from another

I would rather recommend you put your logic into its own Utility/Service class and use it inside as many controllers or commands as you like.  
See [CakeFest Virtual 2021 Day 2 - How to re use code: Utility Classes and PHP Namespaces - Kevin Pfeifer - YouTube](https://www.youtube.com/watch?v=z3E_UdH1XeE) on how to do that

---

<div class="post-metadata">

### Author: ![jarekgol](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jarekgol](https://discourse.cakephp.org/u/jarekgol)
#### Post date: [September 17, 2022, 3:21pm UTC](https://discourse.cakephp.org/t/cron-job-running-on-shared-hosting/10629/3 "2022-09-17T15:21:03Z")

</div>

Also check this [Shells - 3.10](https://book.cakephp.org/3/en/console-and-shells/shells.html) for cron.  
In my case I call it using  
`php full_path_to_script `  
from cron at vps hosting where I don’t have ssh access.  
And as @KevinPfeifer said it is good idea to move somewhere your frequently used code. “Model” it’s good place, every model can be easy accessed from Controllers and other models.
