PHP - Can Someone Setup A Cron Job To Execute A Script For Me?
Hi
I've been stuck trying to execute a script for a few weeks now and I really need help.
The script is supposed to schedule social media posts via functions.php and wp-load.php but I get errors.
Can someone do me a favour?
Drop your email and I'll send you the details to connect to my database.
Thanks
Similar TutorialsGurus, I have coded for my client a PHP script that performs some extensive data munging on text files he creates. Code is complete and I have now to automate the script. Problem is that it seems to *only* run manually. I won't run as CRON job. This is what I have tried with "#!/usr/bin/php -q" in the header of my script: Code: [Select] 00 1 * * * /usr/bin/php -q /HDDLogs/HDDProcess.php >>/HDDLogs/HDDProcess.log 2>&1 The log file does get created but is empty. I tried removing the -q for quiet mode: no difference. Still did not run. Apache 2.0 and PHP 5.3 is installed on this server. I fully own the directory with my code and the data files are located. Any idea?? Thanks, Al. Hello, I have a php script that I'm trying to have run from a different server via cron Code: [Select] 1 9 * * * /usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null The log in /var/log/cron is showing this as having been run: Code: [Select] Dec 26 09:01:01 host crond[10392]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) Dec 27 09:01:01 host crond[17001]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) Dec 28 09:01:01 host crond[2331]: (root) CMD (/usr/bin/wget wget -o http://www.site1.com/update.php -o /dev/null) however it does not appear to run successful (or at least nothing gets updated) Here is the update.php <?php require_once('functions.php'); mysql_connect("localhost","username","password"); mysql_select_db("database"); $result = mysql_query("SELECT * FROM ServerList"); while($row = mysql_fetch_array($result)){ $server = new Whm; $server->init($row['HostName'],$row['UserName'],$row['PassHash']); $NewUsedSlots = count($server->listaccts()); mysql_query("UPDATE ServerList SET UsedSlots='$NewUsedSlots' WHERE HostName='{$row['HostName']}'"); } $CurrentTime = date("Y-m-d G:i"); mysql_query("UPDATE UpdateTime SET TimeUpdated='$CurrentTime'"); ?> update.php does in fact work correctly when I run it from my own personal browser.. what is going wrong? thanks! I am running some php via a cron and I was after the best way to achieve this. Currently I am doing it as follows:- Code: [Select] 0 * * * * lynx -dump http://www.domain.com/script.php This works fine but I don't want anybody being able to run the script by pointing their browser to the file. Any advice on the best method? Cheers. I've got a script that's been running away happily as a cron job for the last few days, but it's suddenly decided to stop working. When I run the script manually it works perfectly, but not when I run it as a cron job. I've done some debugging and I've found that the cause of the problem appears to be an ftp_get function that I'm using. I'm guessing I need to either change a file path, or a file permission, but I'm not sure to what. Here's the info: Code: [Select] $local_dir = '../../col_protected/'; $c = ftp_connect('www.mydomain.net') or die("Can't connect"); ftp_login($c,'ftp_username','ftp_password') or die("Can't login"); ftp_get($c, $local_dir.$filename, FTP_ASCII) or die("Can't transfer"); The FTP connect and login are still working fine, it's the ftp_get that's causing the problem. The '../../col_protected/' directory is on the same level as the public_html (ie. outside the public_html) with file permissions set to 777. The cron is running at /home/username/public_html/col/proc1.php Can anyone advise please? Many thanks, Chris Hi,
I have a cron job that executes this script every 2 minutes:
<?php // LOAD WP-LOAD.PHP require('/opt/bitnami/apps/wordpress/htdocs/wp-load.php'); // INCLUDE AND EXECUTE SCHEDULER.PHP include('/opt/bitnami/apps/wordpress/htdocs/wp-content/themes/yeelloe/scheduler.php'); ?>When I try to include; /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/yeelloe/scheduler.php: <?php // EXPLODE AND PARSE WP-CONTENT; FUNCTIONS.PHP $parse_uri = explode( '/opt/bitnami/apps/wordpress/htdocs/wp-content', $_SERVER['SCRIPT_FILENAME'] ); // LOAD WP-LOAD.PHP require_once( $parse_uri[0] . '/opt/bitnami/apps/wordpress/htdocs/wp-load.php' ); // LOAD TEMPLATE FUNCTION CheckFunction(); ?> <?php error_reporting(E_ALL); $psPath = "powershell.exe"; $psDir = "C:\\wamp\\www\\ps\\"; $psScript = "SampleHTML.ps1"; $runScript = $psDir. $psScript; $prem = "-Action enable"; $runCMD = $psPath. " " .$runScript. " " .$prem; //var_dump($runCMD); $output = exec($runCMD); echo $output; ?>Hello, I am working on a small project to get results from powershell script by using PHP. For some reason in PHP logs I get Exec unable to fork. Above is the script I wrote to execute powershell script within php. My webserver is IIS 7, and app pool is using a domain user that has full rights for Powershell to execute and get remote server results. Seems to be a basic question, but I couldn't find an answer nor figure it out on my own. Basically I have a script that takes out specific data out of the database, the script works on its own, now I just need a way to make the user execute it with a link or a button. Example: Category: [Smileys] - [Category2] - [Category3] - etc. As soon as the user clicks on [Smileys] all data in the database which contains the word smileys in the category field gets selected and outputted as a list. Again the script works, I just need to be able to execute it with a button. If I understood it correctly I have to run the script by adding a if (isset($_POST['Smileys'])) { in front of the script. But how do I build the connection with the text link? Hi all I have this problem on a server using php5, unix based, safe_mode is On globally, i have turned it off locally through php.ini. Ok, this is testing example script i used: $cmd = ( "php -v" ); $out = shell_exec( $cmd ); print $out; On my own server this returns php version. On this mentioned server i'm using (commercial) this causes complete server breakdown, when logged in with SSH, i can't even issue "ls" command after that, nor find and kill the process. What could be so wrong with it? I don't think calling php-cli would make any difference. Hi,
I am a newbie at php and I recently tried making a small php configuration that runs on the localhost. execution.php <?php echo "first script has been executed"; exec('execution2.php'); ?> execution2.php <?php echo "Second script has been executed"; ?> The script is designed to call another php file whereas on the web page I would expect seeing, "first script has been executed" and "Second script has been executed". I am honestly not sure how the execution method is supposed to work however I am not planning on using "include" or "require" since they do not meet my criteria for another project. I am using xampp localhost server on a windows 10 computer. I tried entering "localhost:8080/dir/execution.php" however it did not work.
Any help would be appreciated, thanks! Hi guys, I am new here, and I am a bit stuck with doing something unusual. I want to create a script that can turn on a program (dynamips and dynagen). So far, I have tried 'exec' and 'shell_exec'. Soon I realized that apache runs the commands as 'www-data' user (apache2 in ubuntu) and it's very limited on what you can execute. Is there any way to do that at all? What would be the best practice? I am not concerned about security as this is not a production environment... Thanks How can I achieve the following scenario with an anchor tag? Code: [Select] if(isset($_POST['submit'])) { // execute script } I do need it for a label system to sort content with labels. Hi everyone, i'm trying to get it so when i visit my webpage called start.php it executes the command (/bigbrotherbot start) in the terminal which then should start the process on my linux machine. I'm currently using this code Code: [Select] <?php shell_exec('sudo /bigbrotherbot start'); ?> This script doesn't appear to do anything though. I'm very new to php and would really appreciate the help. P.S the file bigbrotherbot is the bash script which works if i actually go to the terminal myself and type /bigbrotherbot start yet when i try to make the php do it it doesnt do anything. any ideas? Hi,
In reference to my first attached image, I have a form which displays two SELECT/drop-down fields (labeled "Store Name" and "Item Description".....and both of which pull-in values from two separate lookup/master tables, in addition to providing an additional option each for "NEW STORE" and "NEW ITEM").
Now, when first-run, and/or if "NEW STORE" and "NEW ITEM" are not selected from the drop-down's then the two fields in green ("New Store Name" and "New Item Name" are hidden, by means of the following code:
<div class="new-store-container" id="new-store-container" name="new-store-container" style="display:none;"> <div class="control-group"> <div class="other-store" id="new_store_name"> <?php echo standardInputField('New Store Name', 'new_store_name', '', $errors); ?> </div> </div> </div>Conversely, if "NEW STORE" and/or "NEW ITEM" are selected from the two drop-down's then one (or both) of the "New Name" fields are unhidden by means of the following two pieces of code, one PHP and the second JS: <select class="store-name" name="store_id" id="store_id" onclick="toggle_visibility('store_id','new-store-container')"> <?php echo $store_options; ?> <?php if($values['store_id'] == "OTH") { echo "<option value='OTH' selected> <<<--- NEW STORE --->>> </option>"; } else { echo '<OPTION VALUE="OTH"> <<<--- NEW STORE --->>> </OPTION>'; } ?> </select> function toggle_visibility(fieldName, containerName) { var e = document.getElementById(fieldName); var g = document.getElementById(containerName); if (e.value == 'OTH') { if(g.style.display == 'none') g.style.display = 'block'; else g.style.display = 'none'; } }All of that is working just fine. The problem I'm having is that when I click the "Create" button, after having left any one of the form fields blank, the two "New Name" fields are hidden again, which I don't want to happen i.e. I want them to remain visible (since the values of "store_id" and/or "item_id" are "OTH"), so that the user can enter values into one or both of them, without havng to click on the drop-down a second time in order to execute the "on-click" code. The second attached image shows how the fields are hidden, after clicking "Create". How can I achieve that? It would be greate if someone could cobble-up the required code and provide it to me, since I'm relatively new to this. Thanks much. Snap1.png 26.14KB 0 downloads Snap2.png 149.47KB 0 downloads Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Hi
I am not sure if this is the right area for my question, but here goes.
I have a generic script that reads in my wordpress posts and does some pagination.
This code works well on my server (php version 5.2.17):
http://torontomissis...es.com/kath.php
Here is the pdf of the php.ini info: http://torontomissis.../php-5-2-17.pdf
However when I copied it over to another server, the pagination code does not display (php version 5.3.10)
http://blueshiftdesi...g/blog/kath.php
Here is the pdf of the php.ini file info: http://torontomissis...om/php5-3-10.pd
There shouldn't be any reason for this to happen, so I tried to compare the php.ini file from both servers
and there are some differences, one in particular which in the 5.2.17 version
disable_functions is set to "no value" in the 5.2.17 (which works)
and in the 5.3.10 version disable_functions contains a large string of data.
I don't have much experience with the php.ini file so any help is appreciated.
Hi Guys, Just in the process of learning PHP and I am wandering if I need to learn more when finished to complete a certain process. I apologise if this explanation is pretty naff but I cant think of how to word it, but here goes: So what I am looking at doing with a script is creating a place to display information about games, So what I am thinking is there will be a backend where I can kind of add a new game then inside there I can add news articles, videos, images etc. The one thing I cant wrap my head around is if I were to display like trophies for the games like the PS4 trophies, how this would work. So I imaging the backend to be like 'add a game button' then when I click that I get a setup page where I can enter the title, developer, age rating and so on. With the trophies obviously what I am thinking is a text are that will say how many trophies does the game have? So in there I enter let's say 20 then this will add me 20 slots in which I can enter the trophy title, description and points. So my question is when you are creating a form like this where it works off an action like me entering 20 and it producing 20 slots can all this be done with PHP or do I need to be using other code also? Hope that explanation is decent enough. Huge thank you for any advice in advance. Does anyone know how to write the php for a cron job (delete date from a db) this is what I have but it is not doing anything...the cron on my server site runs the code fine but the code does not do anything. Code: [Select] <?php $date = ('Y-m-d'); //Auto delete // Connect to MySQL $connect = mysql_connect("db","username","password") or die("Not connected"); mysql_select_db("name") or die("could not log in"); // Delete entry where date equals today from the "example" MySQL table mysql_query("DELETE FROM boox WHERE date='$date'") or die(mysql_error()); // ?> I'm trying to generate a cron job to run the below script, but can't get it to work for the life of me. Code: [Select] #!/usr/local/bin/php -q <?php if($_GET['key']=="a"){ // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 0){ if($num_results==1){ $message="You have ".$num_results." review unapproved."; } else{ $message="You have ".$num_results." reviews unapproved."; } mail('webmaster@ghosthuntersportal.com','GHP Reviews', $message, 'From: sales@ghosthuntersportal.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 0){ if($num_results2==1){ $message="You have ".$num_results2." RMA Number Requested."; } else{ $message="You have ".$num_results2." RMA Numbers Requested."; } mail('webmaster@ghosthuntersportal.com','GHP RMA Number Requests', $message, 'From: sales@ghosthuntersportal.com'); } echo "Emails Sent."; } ?> Cron Job Command: Code: [Select] php -f /home/zyquo/public_html/ghosthuntersportal.com/cj_run.php?key=a I set the time to run every minute, just to try to get this to work... And in the end I get no emails in my inbox. Ok, I've been trying to figure this out for about 4 hours now. What I am trying to do is update log information from one table to another every 30 minutes. Am I doing this correct? <?php $cron = true; $userinfo = $db->query( "SELECT * FROM users" ); while ( $pulluserinfo = $db->fetch( $userinfo ) ) { $one .= "" . $pulluserinfo['uID'] . ""; //uID is from the users table $two .= "" .$pulluserinfo['Amount=Amount+1000+(TotalAmount*10)']. ""; //Amount & TotalAmount is from the users table $three .= date("F j, Y, g:i a"); //Putting a date $db->query( "INSERT INTO systemlog (`User`,`Amount`,`Time`) VALUES ('$one', '$two', '$three')" ); } $db->close(); ?> Is it possible to have a cron job merely by php ? not by OS (like linux cron). I mean having a php code to repeat a process on with a timer (e.g. every 5min). |