Solved

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

Posted on 2008-06-10
2
597 Views
Last Modified: 2013-12-16
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
Comment
Question by:tate1615
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 21756890
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
 

Author Closing Comment

by:tate1615
ID: 31466027
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now