Linux: send all error to another program (PIPE)
You can use the option : 2>&1 for this purpose. /mycommand.sh 2>&1 | mydescommand.shRead More →
You can use the option : 2>&1 for this purpose. /mycommand.sh 2>&1 | mydescommand.shRead More →
A sample function to use curl post data. $data=array() $data=array(); $data[“field1″]=”hello world”; $data[“user”]=”hello user”; curl_post($url,$data) function curl_post($url,$fields) { //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)’); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields); //some other users translate this array to string, but it will require you to convert some special chars in url such as & //execute post $result = curl_exec($ch); //close connection curl_close($ch); return $result; }Read More →
We first need to list files that are older than number of days (5) find /Data/foldername -name .mp4 -type f -mtime +5 -exec ls -lh {} \; If that is what we expect, we’ll run this command to delete: find /Data/foldername -name .mp4 -type f -mtime +5 -exec rm -rf {} \;Read More →
The service record for ldap and kerberos are used to identify LDAP and Kerberos server for a domain in Active Directory. When you configure some authentication method, it might ask you to specify the LDAP or Kerberos Server. The simplest way to achieve this is using nslookup command. nslookup -type=srv _ldap._tcp.dc._msdcs. nslookup -type=srv _kerberos._tcp.dc._msdcs.Read More →
I built a customize alert, and there are some required fields on the form. User must provide data for these fields. When we build the alert with Addon Builder, the code generated by the builder only validate the required fields when the alert is triggered. This will cause some problems because the user is not aware of this. We can’t use javascript in the html form, fortunately there is a solution, we can use the restmap.conf. This is the sample restmap.conf , you should put it in local\restmap.conf The code below assume that your action name is “youractionname” and the required field is “title”Read More →
There will come a time when you need to start some scripts at startup, but you don’t want to to create it as a service. This is to help you to accomplish that. There are 2 methods: Using /etc/rc.local , this seems only working on Ubuntu 18.04 and older , from version 19, it seems not working. It’s like a bat file in windows, you create that file if it does not exist: nano /etc/rc.local sh /location to your script/script.sh chmod +x /etc/rc.local Using crontab -e , add this line: Read More →
session_set_save_handler(“open”, “close”, “read”, “write”, “destroy”, “gc”); function read($id) { //if we can’t find the data for this session, we must return ” (empty string) , can’t return false return ”; }Read More →
This is mostly because the script is hang at some point , the server still keeps the connection, this will end up where server can’t accept new connection. This is a dirty approach – it will kill all process having waiting time > 30s #/bin/bash #Delete all apache having process with waiting time >30s GetAllWorkers() { AllWorkers=$(apache2ctl fullstatus | grep ” W ” | awk ‘$6>30 {print $2}’) for PID in $AllWorkers; do echo stopping $PID with SIGTERM kill -9 $PID done } GetAllWorkersRead More →
You can run this command:Read More →
Designed using Responsive Brix. Powered by WordPress.