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!
Related
I'm running
nginx 1.17.4
php 7.4
arch linux 5.4.2
Trying to execute the following command to get my user MAC address from IP (this script will run on my lan server) and $_SERVER['REMOTE_ADDR'] does return a valid ip
shell_exec("sudo /usr/bin/nmap -n -sn ".$_SERVER['REMOTE_ADDR'])
But it returns null so I tried the following to get a more info
shell_exec("sudo /usr/bin/nmap -n -sn ".$_SERVER['REMOTE_ADDR'] ." 2>&1")
And got the following: sudo: effective uid is not 0, is sudo installed setuid root?
I don't understand why I get this error because I have added the following in my sudder file
http ALL=NOPASSWD: /usr/bin/nmap
I've modified my passwd to allow login from HTTP to try it in shell and it works but not when I run it in the browser.
Help please!
Thanks
since my server is arch linux I decide to go ask in that arch forum and found was able to fix my issue. so for anybody interested please view
https://bbs.archlinux.org/viewtopic.php?pid=1877560#p1877560
Basically for me it was changing the php-fpm service file to the following
/etc/systemd/system/multi-user.target.wants/php-fpm.service
Set NoNewPrivileges=false
comment CapabilityBoundingSet
I'm developing a Symfony project and I've 4 commands which allows me to update telephony and emails data thanks to OVH' Api. When I use my terminal on local ( php bin/console converseo:updateTelephony ) the command works fine.
Now, I want to put these commands in crontab with the cron interface from Ovh. I made a php file test.php :
<?php
shell_exec("sh test.sh");
?>
And test.sh :
#!/bin/bash
/usr/local/php5.6/bin/php /homez.number/mysite/www/bin/console converseo:updateBilling
And I get the error :
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "converseo:updateBilling" is not defined.
Did you mean one of these?
converseo:updateBilling
converseo:updateEmailCount
converseo:updateTelephony
converseo:updateEmail
The lines are EXACTLY the sames, I don't understand why I get this error.
Thanks a lot for yours answers !
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
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
I try to plan one-time job with 'at' command. There is next code in script:
$cmd = 'echo "/usr/bin/php '.$script_dir.$script_name.' '.$args.'"|/usr/bin/at "'.$time.'" 2>&1';
exec($cmd, $output , $exit_code);
When I run this command from script it adds the job to the schelude. This I see by the line in logs job 103 at Thu Sep 3 15:08:00 2015 (same text contains $output). But then nothing happens in specified time like at ignores the job. And there are no error messages in logs.
When I run same command with same args from command line on server it scheludes the job and than runs it at specified time.
I found out that when I try to plan a job via php script it runs under apache user. I tried to run next in command line on server:
sudo -u apache echo "/usr/bin/php /var/www/pant/data/www/pant.com/scripts/Run.php firstarg secondarg "|/usr/bin/at "16:00 03.09.2015"
It works correct too. I checked sudoers and have added apache user with NOPASSWD privileges. Script Run.php has execute rights.
at.deny is empty. at.allow does not exist.
So question is: why 'at' does not run command given via php script (exec) but runs same command in command line? How to run it?
Thanks to all.
I found by chance answer at stackexchange.com:
The "problem" is typically PHP is intended to run as module in a webserver. You may need to install the commandline version of php before you can run php scripts from the commandline