Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 625
  • Last Modified:

How can I have a bash script create a cron job that runs every 15 minutes?

I want to have a bash script add a cron job that runs a php script every 15 minutes.
I know how to do it using:
export VISUAL=emacs
crontab -e
and then edit it manually.
But how can I automate that in a script?

Also on a sidenote this is the example crontab that the app I am trying to run reccomends:
0,15,30,45 * * * * /usr/bin/php /etc/php.ini /etc/php.d /usr/share/php \ /var/www/html/trellis/core/global/interfaces/event_runner.php

Some of these, like php.ini appear to be config files. Why would any app need config files in a cron job?  Can they even be executed?  That seems awfully confusing right now.
0
tate1615
Asked:
tate1615
1 Solution
 
TintinCommented:
Generically speaking, the way to script adding cronjobs is:

crontab -l >/tmp/crontab
echo "0,15,30,45 * * * * /some/command" >>/tmp/crontab
crontab /tmp/crontab

Open in new window

0
 
tate1615Author Commented:
Thank you very much for your help.  It was very fast, clear, and correct. I appreciate it!
Also what do you make of the second half of the posted question?
Does that make any sense to you?  Why would anyone's lamp web app need a crontab that runs php.ini?  What do you make of it?
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now