Divi WordPress Theme

Topic: How Do I execute a .sh script using cpanel cron job  (Read 1730 times)

Offline Stackoverflow

  • New Member
  • *
  • Posts: 11
  • iTrader: +0/-0
    • View Profile
How Do I execute a .sh script using cpanel cron job
« on: June 14, 2015, 06:59:26 AM »
Hi,

I have a cPanel server and I want to set a cron job to execute mytash.sh script via cron every hour. How can I set the cronjob to execute it every hour?

Thanks!
VPS Hosting - AccuWebHosting

Online Kailash

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 604
  • iTrader: +153/-0
    • View Profile
Re: How Do I execute a .sh script using cpanel cron job
« Reply #1 on: June 19, 2015, 06:54:52 PM »
There are two ways to set cron. If this cron needs to run as root user, you will need to set via SSH.

[1] Set cron as root:

- Login to your server via SSH as a root user
- Execute following command to edit your cron:

crontab -e

- Add following line in your cron:

0 * * * * /path/to/your/script.sh

- Save your changes. Please make sure that your script has execute permissions.

[2] Set a cron for specific cPanel user:

- Login to cPanel
- Go to Cron Jobs
- Set following cron command:

0 * * * * /home/<your_user>/public_html/yourscript.sh

Make sure that your script has execute permissions.

For bot crons, make sure that you set proper path for your script otherwise it will not work.

- Kailash

Offline Stackoverflow

  • New Member
  • *
  • Posts: 11
  • iTrader: +0/-0
    • View Profile
Re: How Do I execute a .sh script using cpanel cron job
« Reply #2 on: July 08, 2015, 04:32:02 PM »
Thank for explaining in detail to set cron job on cPanel server. Really appreciate your help!

hmb-willem

Re: How Do I execute a .sh script using cpanel cron job
« Reply #3 on: January 28, 2016, 12:57:15 PM »
Hello,

Always make sure that correct permissions are assigned to your sh script files. So, they will get execute.

Thank you.
Divi WordPress Theme
Tags: