Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Dynamically Creating A Crontab


Is it possibe to dynamically create a crontab. Say i have a form to enter minute, hour, day, etc... and wanted to create a cronjob that ran to those values. Has anyone done this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating .m3u Files Dynamically
Im looking at creating a playlist program for my server.  i have alist of files within my database, and i wanted to be able to place these values into a playlist file.  the problem is that i dont know how to get the database to create the playlist form its records.  ie, if i uploaded a new file to my server and into the database, then i woudl want the script to automatically grab that file ( SQL  i know), anbd the nplace it in the m3u file ( i dont know).

Coudl someone recommend a simple method to complete this?  or point me in teh righ t doirection for a tutorial?

Creating Queries Dynamically
I've been struggling with a problem for a while and I think that the solution lies in the ability to create queries dynamically. On one page I have a number of drop-down menus created dynamically, so the number of menus can vary. Each drop-down represents a try/touchdown scored, and the user would select from the menu who scored it. On the next page I want to take the info entered and send it to the database, automatically creating new entries for each try/touchdown scored. Code:

Dynamically Creating An Image With Imagecreate()
I have a multitude of images that I am trying to bring up dynamically depending on the scenario. These images are different sizes.
To complicare things just a little more, I am rewriting a javaScript. Am I heading into the correct direction?

Here is the original JS that I am attempting to rewrite: (This is most of the way translated to PHP)

Dynamically Creating URLS Based On User Input !
I am looking to create pages on the fly or dynamically based on user input. For example if i have www.example.com and they visit this and enter 'bob' in a textfield and press submit they create www.example.com/bob.html . How would I go about this ? I am guessing I need to create a folder when submit is pressed in my website directory ?

Dynamically Populate Drop-down List And Dynamically Include Html File
We have a drop down list on a PHP page, with several product names, and
when people click one item, we will refresh the same page with the
product name as parameter, and in turn we want to include a HTML file
into the content area of the same page.

I know it is recommended to put everything into database, but we want
the web site to be very "portable", so the drop-downlist and the
content should both in text files.

Let's say the drop-down list will be poplulated from the product.txt
file, and there will be a file for each corresponding item in the
drop-down list. From the user point of view, if he wants to add a new
product, he will just need to open the product.txt file, and add a new
line with the product name, "Laptop", then add a new text file named
"laptop" in the same folder which contains the HTML fragment to be
included in the content area.

What is the easiest way to do this?

Crontab
Is there any way to call php scripts via crontab? If not is it possible to execute a php sript from inside a perl script i.e. include, require?

Crontab Problem
I have viewed the previous posts on this subject but I'm still stuck. I'm trying to run a php script on the hour which should mail out some reminders. My host has php installed as an Apache module, and I've edited my crontab as follows:

1st try: 0***** lynx http://www.(path to file)
2nd try 0***** wget http://www.(path to file)

Neither work. I have tried the script directly from a browser and it works.

PHP Add Crontab Automatically
I need to create an install file, the purpose is that user don't have to go to CPANEL and add CRON JOBS manually. I need one file, that add CRON JOBS automatically without log into CPANEL.

Here is my function :

function addLynxCron() {
$time = time();
//dump crontab list to text file
$command1 = "crontab -l > ./tempCronLynx$time.txt &";
exec($command1);
chmod ("./tempCronLynx.txt", 0777);
$forFile = "";
$url = $_SERVER['SERVER_NAME'];
$path = $_SERVER['PHP_SELF'];
$cronCommand1 = "lynx -dump */15 * * * * http://$url/cron.php";
$cronCommand2 = "lynx -dump */15 * * * * http://$url/email_cron.php";
$forFile .="$cronCommand1";
$forFile .="$cronCommand2";
$fp2=fopen("./tempCronLynx2$time.txt", "w");
fwrite($fp2, $forFile);
fclose($fp2);
//create new cron jobs
$command1 = "crontab tempCronLynx2$time.txt ";
exec($command1);
echo "crontab successfully added.";
}

The function above is not working...

when I check the file tempCronLynx2$time.txt is correctly written with the
cron jobs I want. But it failed when added the new cron jobs using that files

$command1 = "crontab tempCronLynx2$time.txt ";
exec($command1);

anyone please help with this problems...

PHP, MySQL And Crontab
I have a PHP cli script, that backups my databases, using mysqldump
via system().

When logged in with SSH, and launching the script with "./backup.php",
all works just as it should, but when I put it in a crontab:

00 2 * * * /home/sandman/bin/backup.php

I get a mail that says:

"mysqldump: Got error: 2002: Can't connect to local MySQL server
through socket '/var/run/mysqld/mysqld.sock' (2) when trying to
connect"

How come? Anyone knows what the difference is between CLI and crontab
that could cause this?

Crontab Manipulation From Php
Maybe someone can give me a short help with this...

I got a server application in a LAMP environment doing batch tasks. A
cronjob serves as a regular trigger, a metronom. The trigged
processcollects a number of pending jobs to be run and typically creates a
number of additional jobs to be run in future. The type of created jobs,
their parameters and everything can be configured in the application.
Fine...
In addition I'd like to configure and control the triggering cron job itself
from within the application. Since the web server must not restart the cron
job I can't simply rewrite the crontab. The changes would only become
active after the next reboot, probably some three years in the future
(LAMP :-) ).
What has to be done is to manipulate the crontab of the web server in a way
that the crontab rereads this craontab. crontab -e does exactly this, upon
storing the file the crontab is triggered to read it. However the commmand
requires an editor as argument, this editor is used for the manipulation.
Now I don't really want to control some editor.
I guess I have to specify some process as 'editor' that has access to the
application settings and can open the file. Looks like a lynx or wget call
to a php url, the script should use fopen to open the crontab...

Crontab Entry
How can I have cron back up my database to a new file name each time Ex: db.001, db.002, db003....etc ? What would really be nice is if I could append the current date to the file ? Ex: "db.10-26-00" current crontab entry:

02*** mysqldump -u root -pZXCC helpdesk > /mnt/zip/db.backup

Crontab Outside Web Root
I am trying to get a PHP script running on the crontab where the PHP document is located outside of the web root, this presents a problem because PHP is installed as an Apache module and I dont have access to re-install on this server.

I have searched endlessly for ideas about how to get this running but all I am running into is the usual suspects: CGI Install Call Like a Command Line:

Fetch
wget
lynx

The last three all use http:// protocol as far as I have figured out. So does anyone know of any other software I can use to call from the crontab to run this script.

Update Once A Day If Not Using Crontab?
How is the best way to only run something once a day? I'd rather not run a crontab so how do I do it the least stressful way on the server?

Restricting Script To Run With Crontab Only
I'm creating a re-billing script to process subscription renewals for
a site. I want to use crontab to check once a day for expiring
accounts and re-bill the credit card. This script will only be run
via crontab. Is there a technique that I can apply to prevent access
to the script via HTTP and only execute it via crontab. One thought
was to put the script outside of the public root.

How To Run Crontab From Php Skript As A Different User
I want a php-script to maintain (some of) "my" cron jobs.

Therefore it has to modify some crontab.txt (no problem)
and has to execute crontab.

But since php runs as the apache-user it cannot run "my" crontab.

In general: Can a php-script run an external program under a different
user?

PHP And Crontab And Current Directory
I wrote a script and at the top it checks whether a file exists
like below

if (!file_exists("settings.ini"))
return false;

and the crontab entry:

00 08 * * 4 /usr/local/bin/php /home/user/scripts/test.php /dev/null
2>&1

however everytime it runs via cron, it can't find the file
settings.ini because it keeps looking for it in $HOME not in $HOME/
scripts/ where test.php resides

Why? And how can I re-code it to look in the current directory not in
$HOME? I tried ./settings.ini but without success

Fopen() Wont Work From Crontab
I have a script that calls an fopen() on an external URL.
I can run the script from the server as an url fine.
When however the script should be run from crontab, it does not work.
I get

Warning: fopen(): URL file-access is disabled in the server configuration
in [php-file]

Warning: fopen(http://[url].xml): failed to open stream: no suitable
wrapper could be found in [php-file] on line 66

I have set allow_url_fopen On, but it still wont work. Any Idea what could
cause that?

How To Dynamically Name Variables?
Lets say I have variables named: name1, name2, name3, and name4. How can I call them without having to name them everytime. Something like

for ($i=1; $i<=20; $i++){
if $"name".$i {
do this }

I've tried everycombination I can think of, but am totally confused. I had no trouble naming the variables dynamically in a form, but I can't get php to call them dynamically.

PHP To Dynamically Generate XML
I am interesting in using PHP to dynamically create an XML document and
then use XSLT to transform to XHTML. I have come across two methods for
doing this. I made two equivalent examples so you can see what I mean.

http://members.shaw.ca/petermichaux...SLT_method.html

I am interested in critisim of how I implemented each method. However
my main problem is deciding between methods. Which method is better for
bigger programs where the bits of the XML data are assembled by various
php functions that I write?

For example, one php function queries a database table for a list of CD
titles. A second php function loops through this CD title list and gets
the track listing for each CD from another table in the database. Then
the composite XML data (ie. CD title and tracks as nodes) can be
tranformed to XHTML.

Dynamically Naming Variables
i have this script for that uses 7 pulldowns for the time of an event each day of the week that gets inserted in to a db. Instead of writing the script 7 times for taking the data from the pulldowns, creating a time based on the hour, minute and AM/PM -can i create something that dynamically creates varibles. Basically takes something like $hour1, $minute1 and automatically creates $hour2, $minute2 and so on. This is kinda difficult to explain, heres a snippit of code which i want to duplicate.

Dynamically Incrementing Arrays
I tried searching for this, but couldn't find exactly what I wanted.

Dynamically Resizing An Image
I want to create a thumbnail image. But I don't want to physically resize each
image before uploading it (actually, my client doesn't really have the capability).

Can I dictate a height (i.e. 108 px) and have a PHP script that will
proportionately size down the image using that height? So, if the original is 360 px wide by 540 px high, the image will automatically size to 108 px high by 72 px wide.

How would I do this?

Dynamically Generate Mp3 Clip
I have page in which user will upload song and i need to automatically
generate a 30 second clip of the uploaded mp3 file and save it

can anyone suggest how to do this on linux server which software to use

is it possible with ffmepg or ffmpeg-php to cut a 30 second clip or 60 second clip etc.

if you have any example then please show me how to do that.

Find Domain Name Dynamically
I have 2 registered domains, which point to the same web root folder.
I would like to display a different logo image depending on which domain the user requested. Is it possible to find the domain name with PHP?

How To Change Data Dynamically ...
I'm developing a system where user has a previlage to select
his/her COUNTRY then STATE then CITY respectively. i've put all the
Country names, State names and City name in a Drop-Down combos which
is filled dynamically from the MySQL database. Now my problem is that
i want it in such a way that if one select USA as COUNTRY then all the
STATE(s) of USA should be displayed on the STATE combo not any other.
and then when user selects the STATE in the next combo the CITY combo
should be populated with cities related to that STATE only and not
with any other.

Dynamically Generate Mp3 Clip
I have page in which user will upload song and i need to automatically generate a 30 second clip of the uploaded mp3 file and save it. can anyone suggest how to do this on linux server which software to use? is it possible with ffmepg or ffmpeg-php to cut a 30 second clip or 60 second clip etc

Updating BIND Dynamically
I am about to start an indepth project for the company I work for. We want to use a PHP front end and be able to make updates to DNS dynamically. I was wondering if I can get some opinions on where to start.

Dynamically Populate PDF Form
I found a free script/class online a few months ago which enabled me to populate pre-built PDF forms with data using PHP; without using any toolkits etc (it worked perfectly). It was simply a PHP script. I lost the script when my PC died recently DOH!

Does anybody know where I can find such a script again? I have searched google all night, but all I find is commercial products (not cheap!) or toolkits for generating PDFs', not filling pre-built PDF forms. Here is what I am trying to do:

I have built a site for a client which incorporates e-learning. Students take lessons and if at the end of the course their grades are sufficient, they download a PDF certificate. The certificate is in PDF format with Form Fields for the required data. The certificate needs to display the students name, grade and course name. I need a PHP script which can import server-side data into a PDF form which the user can then print or save (flat). The last (and lost) script did this so I know it is possible.

PHP To Dynamically Make New Pages? DOH!
I am building a CMS system for a client to edit add and remove content from his new site, not a problem however he now wants the facility to create new pages and be able to edit the new pages, how do you create a new page dynamically using php and mysql?

As in he needs to make a new page called untitled2.php for example, with the title at the top of the page, a description about untitled 2 and then save the newly created page so it appears in the menu and actually exists in the remote server files, then be able to edit this using the CMS system? ERM...

Any standard commands as in create_page()?

How would I make the new page have variables included so that it could echo mysql content onto the newly created page?

Dynamically Transparent Gif's
Basically what i would like to do is dynamically set the transparency of a selection of images (GIF'S) depending on variables set in a My SQL Database. What i need to do is tint some jpg,s by setting the transparency of a solid blue gif which is set over the top of it in a table.

How To Append A Child Dynamically
i m new in both things php and in this group.
but i have some basic knowledge of php and DOM in php.

here is my problem,
i have one textfield for add a new main node (not main like:
<root><this_one></this_one></root>) in my php page and i m able to save
the xml file correct with this, and in the bottom of that i have one
new textfield for add new child in dynamically create node (which i
descibe above),and one combo box for show the all dynamically create
nodes.now i want that when user give the value in child textfield and
then select a root node for that child from combo box.i want to append
a child dynamically to root node.

but i m not able to do this. plz try to solve my prob...

Managing Subdomain Dynamically
i don't know if php can do it, here is the picture, what i want is a cheaper way of doing this stuff, newdomain.mydomain.com, cuz when i use the feature of the ISP, it will cost me $1/subdomain per month. any ideas?

Dynamically Load A Class
I want to dynamically load a class using a variable, e.g.

$module = new Mod_{$tmp_Name} ();

Where $tmp_Name is the name of the class.

Is there anyway to achieve this kind of thing?

Dynamically Embedding SWF File In PDF From PHP
is there by any means can i embed a swf file and export the same to a
pdf from my script.

Dynamically Updating Database
I have drop-down menus created on a previous page, created dynamically so the number of them varies. When the form is submitted I need a script that will automatically add 1 to the value in the playerTries column in the players table, for every drop-down menu. I've tried the code below but don't fully understand what's happening, and why it's not working. Code:

How To Get Value From A Dynamically Created Textbox
how to get value from a dynamically created textbox using php

Editing MP3s Dynamically
I'm trying to work out if there's a way of using PHP to dynamically edit an MP3. Is this a bit too much for the old PHP to handle? I just want to cut it down to 10 seconds of audio if possible.

Dynamically Create New Web Page
i'm making a cms, and I have a good portion done, I have it set up where the admin can log in and create a new post which goes to the database. I am just wondering how I can make this post a new web page? I have been trying to study how they do it in wordpress but with no avail. Anyone have any suggestions?

Dynamically Populate A Drop Down Box
I have a website with products for sale and along side each item I have displayed the number of each of these items that are left in stock.  What I want to do is to have a dropdown box so that the user can choose the qty of itmes to order but they should not be able to order more than what is in stock.

For example if there are 5 items left then the drop down box must be initialised at 0 and show the numbers 1,2,3,4,5.  When a purchase is made then the drop down must be adjusted to match what is left in the database. Code:

Dynamically Naming Variables
I'm pulling values from a db, the values are all domain names. Is there any way after pulling them in with a while loop, that I can define a variable name as the value of what I have pulled?

$query = "SELECT city FROM cities ORDER BY city";
$results = mysql_query($query);
while ($row = mysql_fetch_array ($results, MYSQL_ASSOC))
{
           $thisiswhereIwantTheValueToGo = $row['city'];
}

I understand that the above will make the value of the variable = to the $row['city'], is there any way I can dynamically create the variable name based on that same value?

Add Fields To A Form Dynamically On The Fly
I'm looking to create a form the allows the user to input a simple list item by item. However I am not sure how to implement a form that allows the user to add as many fields as the need on the fly.

Dynamically Create And Save Php Page
Here is my code:
$filepointer=fopen("http://www.mysite.org/usersetup/newusers/" . $SESSION_UID . "/configsite.php", "w+");

$data = "<? $name = ' . $datatosave. '
?>";

fputs($filepointer, $data);

fclose($filepointer);

My goal is to dynamically create a .php file with the contents of
<? $name = "variable data"; ?>

My code doesn't work. Something with the php page, I think. I and using similar code to populate .txt files with dynamic data, without variables, and it works file. Apparently, a quick change to .php is harder than I thought. I"ve even tried sending a simple line of data to the php page with no luck. Heck, I even tried doing it as a text file and rename to .php but it didn't like my rename.

Dynamically Generated Results Table
I'm trying to write a script that dynamically generates HTML tables depending on the results from an SQL query. So far, I have managed to set the HTML table headers to be the same as those in the MySQL table. [thanks to rod k -cheers !]

Now i'm trying to put the results in the table. Basically, I need a MySQL function to retrieve data and put it into the table until there is no data left....

(At the moment I am using "mysql_fetch_array()", but with this it is necessary to know the names of the columns to retrieve the information for each result set. Since my table is dynamic and should be able to build itself from different MySQL tables, the column names aren't fixed and so i can't use this to put the data in the tables...)

Getting Dynamically Generated POST Data
I'm trying to get POST data that was dynamically generated and I'm not sure how to go about doing this.

How To Dynamically Generate Functions In A Class
I am having to be tasked with a rather painful task of updating an
existing class by adding a dynamic amount of database field values;
for each database field value there has to be a generated array inside
the class plus a function "get method" to return it.

I do not want to have to constantly type out:

function getStuff() {
return $this->stuff;
}

for every occurrence of stuff I find that is generated by the database
SELECT call on the fields of as many as 20 different tables!! This is
enormous and I would love a more dynamic, functional method to
generate.. methods.

Saving A Dynamically Created Png Image
I have a web site that responds to a user request by sending an image generated dynamically. the request page call is something like this
<img id = "picid" src= "generateimage.php?$picName">

Where $picName holds the parameters needed for a particular image

generateimage.php sends the request to the server which generates the image as $pngstr and responds:

header("Content-Type: image/png".chr(13).chr(10));
header("Content-Length: ".strlen($pngstr).chr(13).chr(10).chr(13).chr(10));
echo $pngstr;

Now, I want the user to be able to right click the image and save it with a given name - related to but not exactly $picName, as a png.

I also have a set of images forming an animation generated in much the same way as the single image described above. How could I have the user save these? is there an animated png yet?

How To Get Full Address Of The Website Dynamically?
how to get full address of the website dynamically?
like www.yahoo.com/op/guy/123/
using server var($_SERVER).

i just want path till current working dir from www.yahoo.com/op/guy/123/ page.php i don't need it.

Dynamically Change META Tags
I am just wondering, if it is possible to dynamically change META tags through the use of PHP?

Any help is much appreciated. And yes, i am a beginner, on page 93 of Sam's PHP & MYSQL web development...

Dynamically Filling Selection Boxes
I was wondering if anyone knows how to fill a selection box with different values depending on a selection made in a nother selection box in the same page. I dont know if what I'm tryin to do can be done or not, at least in PHP. First a quick background:

We have a number of projects running right now, each of which is subdevided into various tasks. Now, I've got two selection boxes. The first contains a list of all current projects. What I want to do is this: when someon selects a project from the first box, I'd like the second box to be filled with a list of the tasks that have been assigned tot hat project.


Copyright © 2005-08 www.BigResource.com, All rights reserved