Cron Job on dreamhost server - php

I am trying to run a script not hosted on dreamhost control panel cron job. I have tried in 2 seperate cron jobs:
wget -q -O /dev/null http://othersite.com/api/script.php
-and-
/usr/local/php56/bin/php "http://othersite.com/api/script.php"
With the later outputting an error message:
Could not open input file: http://othersite.com/api/script.php
Any suggestions? Thank you

Related

task scheduler on windows throws error "2147942402"

I am trying to schedule a task in windows task scheduler what i want is have to run a url every 5 minutes without opening browser i tried using
php -f http://localhost/sms/test.php
wget -q -O - http://localhost/sms/test.php > tmp.txt
and also the full path
php -f C:/Bitnami/redmine-2.4.3-0/apache2/htdocs/sms/test.php
it shows the same error
Task Scheduler failed to start instance
"{a889332e-87f0-421b-accc-4ff19ae98599}" of "\test" task for user
"PUGOSTECH\xxxxx" . Additional Data: Error Value: 2147942402.
I understand that i am making a silly mistake to create scheduler but dont know how to find?
If i use by opening browser command it works fine like
cmd /c start http://localhost/sms/test.php

PHP Add scheduled task in Linux "PAM failure System error"

Im running this code in my php file:
shell_exec('echo wget http://192.168.20.1:8080/proj/add_user/ | at -t 201606281053');
in my var/log/httpd/error_log, it says "PAM failure System error".
I'm trying to add a scheduled task in my server but this doesn't seem to work.
I refer to this thread but no success.
how to pass arguments to linux at command
Thank You!

Running continuous PHP applications on free Heroku

It is possible to run continuous PHP applications on free Heroku?
I run the PHP irc bot via browser by this code:
<?php
exec("(cd php-irc;/app/php/bin/php ./bot.php bot.conf &) > /dev/null 2>/dev/null &");
?>
Bot turns off after about an hour :(
As suggested jszobody I use background jobs.
I executed
heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
and created Procfile with contents:
web: sh boot.sh
worker: cd ~/php-irc/ && php bot.php bot.conf
and executed:
heroku ps:scale web=0 worker=1
Seems it works without problems. Thanks!

How to start a remote PHP script via cronjob (alternative to wget)?

I need to start a remote PHP script (example.com/cron.php) every minute with a cronjob. At the moment, my cronjob looks like this: wget example.com/cron.php. This works, but puts a cron.php file on my server every time. How can I prevent this? Or are there alternatives to wget?
Quoting from manpage for wget:
-O file
Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there.
That means that -O - redirects output to stdout. And output on stdout you can simply redirect to /dev/null:
wget -O - http://example.com/cron.php >/dev/null
if your sever has lynx installed you could do lynx example.com/cron.php or you could use curl and do curl example.com/cron.php
This solution is for linux server:
To execute a cron job you need to have access to cronTab on the server:
to edit crontab use the commnad line :
sudo crontab -e
add a the script you would like to execute:
* * * * * php /path/to/your/script/cron.php 2>&1
Save your crontab and you should be done.
Please check the link http://en.wikipedia.org/wiki/Cron to understand the asterisk
Check out https://www.setcronjob.com/
This web program enables you to automatically schedule cron jobs on other servers.

GoDaddy Cron Job issue with Shell and Perl Script

i created a Cron Job on my GoDaddy Server, named "SponUpdate.sh"
here is the code for this file
#!/bin/bash
/usr/bin/perl /home/content/14/5959214/html/cgi/JLLoadSponFRJ.pl
/usr/bin/perl /home/content/14/5959214/html/cgi/JLLoadSponMGJ.pl
/usr/bin/perl /home/content/14/5959214/html/cgi/JLLoadSponCAD.pl
/usr/bin/perl /home/content/14/5959214/html/cgi/JLLoadSponCJB.pl
Now the issue is when this cron Job Runs it says me following Error,
"/bin/sh: /var/chroot/home/content/14/5959214/html/cgi/SponUpdate.sh: /bin/bash: bad interpreter: Permission denied"
here is the code for one of Perl File "JLLoadSponFRJ.pl"
my $command = '/web/cgi-bin/php5 -q $HOME/html/GISJobs/JLLoadSpon.php';
exec ($command) or print STDERR "couldn't exec $command: $!";
i am unable to resolve it from last 3 days,
Please help me,
Thanks in advance,
Regards,
So you're launching a cron job that runs a bash script that calls some perl scripts that call php. Why don't you just call php directly from cron?
Check that your bash script does not contain "\r\n" line endings: You might be trying to invoke "/bin/bash\r" instead of "/bin/bash"
You can check the bash path with which bash and then you can correct the shebang !#/bin/bash of the perl script.

Categories