Re: Running PHP File under Crontab...
There are a couple of ways. My prefrence is to control the output directly from the app in PHP. However you should be able to pipe the output to a file without issue. Cheers, m! On Jan 17, 2010, at 15:48, Diego Montalvo wrote: One other question, is there a way to copy the ouput of the crontab "php" file to another file? Simply the "hello world" output and not the code... ?? 2010/1/17 mikel king : On Jan 17, 2010, at 3:01 PM, Diego Montalvo wrote: I am using " 2010/1/17 mikel king : On Jan 17, 2010, at 2:30 PM, Diego Montalvo wrote: CLI meaning, if I can run and excute in command line, a php file can run in crontab? doing the following in shell: "# php helloworld.php" - "hello world" is produced... Thanks! ok then do you have #!/usr/local/bin/php as your first line of the script? Or are you using the bash exec command to run the code in your shell script? Also you can try placing the path to the php CLI executable in the crontab. If your php executable is in /usr/local/bin then replace /bin/sh with that in your script file. #!/usr/local/bin/php Remember to chmod +x the script file. m! ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org " ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
One other question, is there a way to copy the ouput of the crontab "php" file to another file? Simply the "hello world" output and not the code... ?? 2010/1/17 mikel king : > > On Jan 17, 2010, at 3:01 PM, Diego Montalvo wrote: > >> I am using " >> >> 2010/1/17 mikel king : >>> >>> On Jan 17, 2010, at 2:30 PM, Diego Montalvo wrote: >>> CLI meaning, if I can run and excute in command line, a php file can run in crontab? doing the following in shell: "# php helloworld.php" - "hello world" is produced... Thanks! >>> >>> >>> ok then do you have #!/usr/local/bin/php as your first line of the >>> script? >>> Or are you using the bash exec command to run the code in your shell >>> script? >>> >>> Also you can try placing the path to the php CLI executable in the >>> crontab. > > > If your php executable is in /usr/local/bin then replace /bin/sh with that > in your script file. > > #!/usr/local/bin/php > > > echo "Hello cruel world!!!\n"; > > ?> > > Remember to chmod +x the script file. > > m! > > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
On Jan 17, 2010, at 3:01 PM, Diego Montalvo wrote: I am using " 2010/1/17 mikel king : On Jan 17, 2010, at 2:30 PM, Diego Montalvo wrote: CLI meaning, if I can run and excute in command line, a php file can run in crontab? doing the following in shell: "# php helloworld.php" - "hello world" is produced... Thanks! ok then do you have #!/usr/local/bin/php as your first line of the script? Or are you using the bash exec command to run the code in your shell script? Also you can try placing the path to the php CLI executable in the crontab. If your php executable is in /usr/local/bin then replace /bin/sh with that in your script file. #!/usr/local/bin/php Remember to chmod +x the script file. m! ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
> I am wanting to execute a PHP file 5 times a day via crontab. Is it > possible? If so what is the proper crontab command for this? Hi. I'm running several PHP programs via cron. #1 Make sure you have CLI (command line interface) in your PHP port: As root, > cd /usr/ports/lang/php5 > make config Then make sure the "CLI" is set to "on". If it isn't, change it, and recompile the port. For example "portupgrade -f php5-5.2.12" will recompile the port, if you have portupgrade installed. #2 Write the PHP script you want to run. There are different syntaxes for writing a command-line PHP program but here is one of them: Save this to a path "/path/to/mycode.php". #3 Add cron job to execute this program. Your crontab should look like this: */5 * * * * /usr/local/bin/php -f /path/to/mycode.php (That would execute your PHP script every 5 minutes for example.) That's it! There is an alternate way to write PHP scripts for CLI, but I have not used it extensively, so I don't know all the details or the correctest way to do it. You can write a script like this: #!/usr/local/bin/php And then save it to a file for example "test.php" and set the executable permission on it. Then you can just: ./test.php from a terminal. So you could change the cron to just execute the script directly in this case instead of explicitly calling /usr/local/bin/php in the crontab. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
I am using " 2010/1/17 mikel king : > > On Jan 17, 2010, at 2:30 PM, Diego Montalvo wrote: > >> CLI meaning, if I can run and excute in >> command line, a php file can run in crontab? doing the following in >> shell: "# php helloworld.php" - "hello world" is produced... >> >> Thanks! >> >> > > > ok then do you have #!/usr/local/bin/php as your first line of the script? > Or are you using the bash exec command to run the code in your shell script? > > Also you can try placing the path to the php CLI executable in the crontab. > > > > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
CLI meaning, if I can run and excute in command line, a php file can run in crontab? doing the following in shell: "# php helloworld.php" - "hello world" is produced... Thanks! 2010/1/17 mikel king : > > > On Jan 17, 2010, at 1:28 PM, Diego Montalvo wrote: > > I am wanting to execute a PHP file 5 times a day via crontab. Is it > possible? If so what is the proper crontab command for this? > > Thanks, > Diego > > Diego, > Certainly, but you must ensure that you have the CLI version of PHP > installed. > > Regards, > Mikel King > CEO, Olivent Technologies > Senior Editor, BSD News Network > Columnist, BSD Magazine > 6 Alpine Court, > Medford, NY 11763 > o: 631.627.3055 c: 631.796.1499 > skype:mikel.king > http://olivent.com > http://mikelking.com > http://twitter.com/mikelking > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Running PHP File under Crontab...
On Jan 17, 2010, at 1:28 PM, Diego Montalvo wrote: I am wanting to execute a PHP file 5 times a day via crontab. Is it possible? If so what is the proper crontab command for this? Thanks, Diego Diego, Certainly, but you must ensure that you have the CLI version of PHP installed. Regards, Mikel King CEO, Olivent Technologies Senior Editor, BSD News Network Columnist, BSD Magazine 6 Alpine Court, Medford, NY 11763 o: 631.627.3055 c: 631.796.1499 skype:mikel.king http://olivent.com http://mikelking.com http://twitter.com/mikelking ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Running PHP File under Crontab...
I am wanting to execute a PHP file 5 times a day via crontab. Is it possible? If so what is the proper crontab command for this? Thanks, Diego ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"