I have installed webmin on my centos linux server.
I want to set a cron or list cron jobs using API which I can call through any python or php code.
I tried finding any such thing on internet and in webmin documentation, but couldnt find anything.
Has anyone tried this or knows how this thing can be implemented ?
I know I can create a PHP api or python api , which in turn can run shell commands to add crontab, but I am looking native-webmin API.
https://doxfer.webmin.com/Webmin/XML-RPC_Calls documents a way to perform rpc calls. You can, for example, execute such a call using curl with
curl --data #testcall -k https://root:changeme#192.168.0.100:10000/xmlrpc.cgi
where the content of testcall is
<?xml version="1.0"?>
<methodCall>
<methodName>useradmin::list_users</methodName>
<params>
<param>
<value>apiUser</value>
</param>
<param>
<value>apiKey</value>
</param>
</params>
</methodCall>
Related
How do i set the cron command in Cpanel in Linux server i use this it works for me is there any proper way
wget http://www.vloghit.com/crons/send_mail
You should use the full path for wget like /usr/bin/wget instead of just plain wget. Depending on the WHM server configuration the crons might be running as jailed so you might get an error stating that wget command was not found if you do not use the full path to the binary. You are also supposed to receive an email notification from that cron job. Are you geting it? I'm asking because in those email notifications you get also an error message that can help you to understand why the cron was not working.
how can we access an Apache server using a Linux command, to retrieve file.
the file which is to be retrieved has been copied to a directory.
Without knowing more about what you are doing, I would suggest looking into wget or curl.
For example: to copy a file available on a web server via url to the current directory using the wget command:
wget http://www.example.com/path/to/file.txt
or, if you are accessing your web server by IP address:
wget http://192.168.1.1/path/to/file.txt
What is purpose of "wgetrc" in the below commands.
-sh-3.00$ WGETRC=/hom1/spyga/spp/wgetrc_local wget --directory-prefix=/home1/spyga/spp/download ftp://127.0.0.1/outgoing/DATA.ZIP
wgetrc_local files having the credentials of ftp server.
normally i am downloading the files from ftp server using below command.
-sh-3.00$ wget --ftp-user=xyz--ftp-password=12345 ftp://localhost/outgoing/DATA.ZIP
what is the different between above commands.
Please help me out to understand the commands.
Thanks you.
The first command simply specifies an alternative configuration file to use instead of the default ~/.wgetrc. You could also specify it using --config=/hom1/spyga/spp/wgetrc_local as argument to wget.
This file can contain wgetrc commands that change the behaviour of wget. In this case it's probably done so user and passwords don't have to be supplied on the command line. Specially on multiuser systems it is a security risk to pass passwords on the command line, as that can possibly be viewd by other users, so it's a little better to store them in a file with restricted access permissions instead. This way only processes started by the owner of the file can access it.
Another use of the wget startup file is to change it's default settings, user agent etc...
It's all documented here.
I need to contact a server (perhaps Apache) running on a Linux box and have it return the following results. I am new to networking, but can write code in Java, PHP and maybe a little C.
I need to remotely run diagnostic tests from the Linux box on the local area network. Ultimately these tests need to be delivered to a web page on the client side.
I am not sure where to begin on this project and appreciate any suggestions or general strategies. I am familiar with a command written in Java (i.e., Runtime.getRuntime().exec("ping -c 1 " + ip); ), but I don't know if it is necessary to involve Java and I don't know how to startup a Java program on a server and return it to a PHP file. Is it possible to do this without involving Java? Again any specific or high- level suggestions are appreciated.
Perhaps you are looking for the exec function in PHP?
You can use exec function
-for ping:
//ping.php
<?php
exec ("/bin/ping -c 5 www.google.com", $response);
echo "<pre>" . join("\r\n", $response)."</pre>";
?>
use the php command-line in terminal
$ php ping.php
Hi I want to run a cron job to call a PHP script on my server. I am using Cpanel from my web host and these are the options:
Minute:
Hour:
Day:
Month:
Weekday:
Command:
I am really struggling to point the command to my file I am using this line /home/abbeysof/public_html/adi/cron/daily.php but I am getting this error:
/bin/sh: /home/abbeysof/public_html/adi/cron/daily.php: Permission denied
I asked my web host for help and this is the response:
If you use cpanel to create it, it will fill in the path for you. Typically /home/username/public_html/etc
Can anyone please offer some advice?
Advise 1: use wget command, wget runs the PHP script exactly as if it was called from the web so the PHP environment is exactly the same of when calling the file from the web, it's easier to debug your script then.
wget -O - http://yourdomain.com/adi/cron/daily.php >/dev/null 2>&1
The cron jobs has to be created going into cPanel cron jobs menu. I don't understand if you have this clear by reading your hoster's answer.
And advise 2: change web hosting, try this one they don't leave you alone.
Sorry, I don't know anything about cpanel, but it sounds like:
if you created the file daily.php, then you need to change the permissions on it
if they created the file, then there's a bug in their creation routine.
Good luck!
try this one
/usr/bin/php -q /home/yourCpanelUsername/public_html/filename.php
for some cpanels it might be like this
/usr/local/bin/php -q /home/yourCpanelUsername/public_html/filename.php
Sounds like you need to make /home/abbeysof/public_html/adi/cron/daily.php executable.
The link might help you.
https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job
There is difference if you are using VPS than sharing hosting for giving the command.
You may need to use user-agent & cPanel-Cron along with your url.
curl --user-agent cPanel-Cron http://example.com/cron.php