I have a simple PHP script that checks the PDO SQL connection and the script does something after that.
The problem is when I run it as a scheduled task from windows schedule even from a batch file or directly by running from the scheduler with php.exe -f "script file"
the command prompt window appears and this is relay annoying.
Is it possible to disable the cmd popup when running the script from scheduler?
On Task Properties, in General Tab, there is a option called as "
Security Options
On this options, choose the second option which is
Run whether user is logged on or not
After saving, it will ask your admin credentials. Enter your credentials, then your scheduler will not show any cmd window.
Try use wget with -q. I have a machine with Windows Server 2012 + Apache and a scheduled task for every 5 minutes and using wget it didn't show any command prompt window.
I downloaded wget from http://gnuwin32.sourceforge.net/packages/wget.htm
It is a tricky thing. You can try to use the task.exe tool from the PHP SDK under the default task scheduler. Another option were to use an alternative cron implementation, for example a UNIX like nnCron.
Related
I run various PHP scripts from the Windows 10 Task Scheduler, and the command prompt window closes after running them. Is there a way to pass an argument from the task scheduler interface to cmd.exe so the Command Prompt window doesn't close after running a specific PHP script? If so ... How?
Thank you, Your comment led me to this useful bit of php code: exec(`cmd /K`);
I am developing application in codeigniter ,i want to run my controller method every mid night where i am updating status of some table field according to date wise.
I know it can be done using cron job with cPanel ,but client does not have cpanel ,he has only ftp details,so any one has idea how i can set cron job using ftp ? any script which run automatically?
Thank you.
Normally CLI from Codeigniter require access to SSH terminal to add a cron job via crontab -e or if you have cpanel via cronjobs panel.
The solution can be if you can call the address via GET so in this case you can add a cron job in another server and call that address with GET.
Add cron via SSH on shell:
Login to SSH shell via Putty on Windows, Terminal on Mac and Terminal on Linux:
Type: crontab -e
(If you don't have an editor pre-selected it will ask you to choice one, i recommend "nano")
Add a new line:
59 23 * * * /path/to/codeigniter/index.php controller Method
and it will call every day at 23:59 the Controller "controller" and Method 'Method"
Cheers
You will not be able to set up a cron job on your server using ftp. What you could do is put all the script you want to run in a single page and use a service like www.pingdom.com to visit that page every midnight.
Dan
How would you run a windows task schedule to open a webpage, post login information and then run the url?
Background:
CRM has crons that were setup for a linux only. It has a manager where I can run the jobs as well manually. I want to run the web url that does these jobs manually through the windows server but requires that each time it connect it login with a specific user.
How would I setup a scheduled task on windows server that :
1. Opens and Logs into page then runs the url for the manual job.
Runs every minute
So essentially it needs to look like this:
http://thewebsitename.com/?username=someuser&password=apass
http://thewebsitename.com/theurltorunjobmanually.php
Can scheduled tasks run a php command instead as well? For example if I set up a WGET script, could the scheduler run that php script? Have not been able to figure out how to do this, linux seems to be pretty easy in this scenario
This could be as simple as:
Download wget for Windows
Create a batch file with the following contents:
wget --post-data "username=someuser&password=apass" http://thewebsitename.com/
wget http://thewebsitename.com/theurltorunjobmanually.php
You also asked about running a PHP script via the scheduled task, you can add this line to the batch script:
C:\path\to\PHP.exe script.php
Not sure if you're looking for methodology or an actual solution, but we have a process somewhat like this where we need to login to our CRM and run an upload, task creation process at regular intervals. Used to be manual but now we use an automation software product, Foxtrot. You can find it here for whatever it is worth: http://www.enablesoft.com/foxtrot-professional/
You can put the cURL or wget commands in a batch file or PowerShell script and have the Windows Task Scheduler call it.
Is that possible?I know how to refresh a page with header commands or javascript but this demands that the user will constantly have a browser opened.I want to build an automated bot that will not need my computer opened all the time.
Run the PHP script from a command line with your CRON or Windows Task Scheduler. Create a new Task, and execute that task as often as you like without a user or a browser.
C:\php\php.exe -f C:\My_Folder\My_Script.php
So you want to execute your script independently of web-calls, the usual approach would be to launch your PHP-Script using cron.
You can also use 3d party service such as https://www.setcronjob.com/ as "external" cron - if the intervals are not too narrow...
I need to run a php script at the scheduled time daily to update some fields in database and to send automated email. How I can do this?
Is it possible to write some service in XAMP server to run the script daily at scheduled time? I have no idea how to update database and send email automatically at the scheduled time. Can any one share some ideas or concepts?
I am using PHP and MySQL running in Linux Server.
You should use a Cron job to do it. Check out the examples on the Wikipedia page.
The Cron Job should call a script using the php executable that runs the necessary task.
Just create the script that does the required job, test it by hitting the URL in your browser once you are sure it works right. Copy the URL and add a Cronjob
Then schedule this command to run at whatever time you want to run
php ABSOLUTE_URL_TO_SCRIPT >> logfile
The log file is optional. But it will give you a chance to see what happened.
For example if you want to run your script every 4 hours, and assuming your script is at http://localhost/work/scripty.php and assuming that your http root is /var/www,
you would run "crontab -e" in terminal and add the following line:
* */4 * * * php /var/www/work/scripty.php
If you need more information just comment I will update the answer.
PHP cannot run script by itself,since php doesn't have daemons like python !!
So you have to take OS help to invoke your custom script .
For example in linux :
(example.sh)
export USE_PHP=php
cd $SCRIPT_ROOTDIR
$USE_PHP -f cronfile.php service="checkdatabase"
(service is the parameter passed to your cronfile).
For setting up cron jobs ,have a look at this link
http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
In Linux, We can create .sh file and can give a specific time to run that is called cron job.
SO should use this method just make a shell file and give a time period to it.
You should take a help with linux expert for that.
Use the following: Cron Job