1

I want to make many tasks(different shell script) run with crontab by clicking on a button on website to start all tasks specified in crontab. Is it possible to do this? Please provide me the recommendation.

4
  • 3
    You can run shell scripts by triggering them via web server. However, this has nothing to do with crontab which is a technique for running scripts triggered by time only. Commented Jan 16, 2020 at 22:59
  • 1
    you could have crontab run a script that checks if the button was clicked Commented Jan 16, 2020 at 23:03
  • @Ned64 can you then tell us please how to run such a shell script via the web browser please. Commented Aug 28, 2021 at 6:37
  • 1
    @MoisésBriseñoEstrello I would suggest somethink like the answer by Yevhen Stasiv below. One could either have php execute something server-side, or have it "drop" a flag file which would then be detected by a local script (more flexibility and security, avoiding exec). Commented Sep 14, 2021 at 11:36

1 Answer 1

2

As you are looking for an 'on demand' click of the button script execution, you do not need to use crontab.

You can simply use something like PHP's shell_exec() or exec() to achieve your goal.

If you wish to execute previously set up crons on demand, something like run-parts /etc/cron.daily can be passed to the above functions.

1
  • 2
    This is exactly what I was looking for, the exec() function worked perfectly, thank you! Commented Aug 3, 2020 at 17:57

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.