Search code examples
linuxcronquartz-schedulercron-task

How to run the shell script in cron job in specific time at only once per day


I just wanna run a .sh file everyday 9AM PST. I just created scheduler in crontab in linux as like below

* 9 * * * /home/arrchannaMohan/PaymentsAlert.sh

PaymentsAlert.sh

curl -k http://localhost:8080/emailTrigger

The above curl command will trigger email with some business content every day 9 AM PST and It should run one time per day. So every day 9AM PST this shell script should be invoked one time.

But the above cron configuration will start initiating the email alert every 1 minutes interval after 9AM PST and its keep continuing until we kill it manual.

Is it possible to create a cron config that will run once a day(Expecting to run 9AM PST).


Solution

  • The crontab you've listed means;

    * 9 * * *
    > At every minute past hour 9
    

    You'l need 0 9 * * * since you only want to job to run on the whole our, hence the 0 minutes.

    0 9 * * *
    > At 09:00
    

    Use something like crontab.guru to visualize it.