정보

Windosws에서 서비스는 사용자 관리자(service.msc)에 의해 실행

리눅스의 경우 명령어 뒤에 &를 붙여서 백그라운드 실행가능

Windows의 경우 sc.exe를 실행하여 생성 가능

 

등록 방법

telegraf.exe을 등록하는 예
(관리자권한으로 cmd 실행)

sc create telegraf_agnet binpath= "C:\Program Files\Telegraf\telegraf.exe" displayname= "telegraf_Agent" start= auto

(참고) 서비스 삭제
sc delete telegraf_agent

 

참고

https://docs.microsoft.com/ko-KR/windows-server/administration/windows-commands/sc-create

https://gentian.tistory.com/1

mysql 8.0 기준

Table 12.11 Date and Time Functions

NameDescription
ADDDATE() Add time values (intervals) to a date value
ADDTIME() Add time
CONVERT_TZ() Convert from one time zone to another
CURDATE() Return the current date
CURRENT_DATE(), CURRENT_DATE Synonyms for CURDATE()
CURRENT_TIME(), CURRENT_TIME Synonyms for CURTIME()
CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP Synonyms for NOW()
CURTIME() Return the current time
DATE() Extract the date part of a date or datetime expression
DATE_ADD() Add time values (intervals) to a date value
DATE_FORMAT() Format date as specified
DATE_SUB() Subtract a time value (interval) from a date
DATEDIFF() Subtract two dates
DAY() Synonym for DAYOFMONTH()
DAYNAME() Return the name of the weekday
DAYOFMONTH() Return the day of the month (0-31)
DAYOFWEEK() Return the weekday index of the argument
DAYOFYEAR() Return the day of the year (1-366)
EXTRACT() Extract part of a date
FROM_DAYS() Convert a day number to a date
FROM_UNIXTIME() Format Unix timestamp as a date
GET_FORMAT() Return a date format string
HOUR() Extract the hour
LAST_DAY Return the last day of the month for the argument
LOCALTIME(), LOCALTIME Synonym for NOW()
LOCALTIMESTAMP, LOCALTIMESTAMP() Synonym for NOW()
MAKEDATE() Create a date from the year and day of year
MAKETIME() Create time from hour, minute, second
MICROSECOND() Return the microseconds from argument
MINUTE() Return the minute from the argument
MONTH() Return the month from the date passed
MONTHNAME() Return the name of the month
NOW() Return the current date and time
PERIOD_ADD() Add a period to a year-month
PERIOD_DIFF() Return the number of months between periods
QUARTER() Return the quarter from a date argument
SEC_TO_TIME() Converts seconds to 'hh:mm:ss' format
SECOND() Return the second (0-59)
STR_TO_DATE() Convert a string to a date
SUBDATE() Synonym for DATE_SUB() when invoked with three arguments
SUBTIME() Subtract times
SYSDATE() Return the time at which the function executes
TIME() Extract the time portion of the expression passed
TIME_FORMAT() Format as time
TIME_TO_SEC() Return the argument converted to seconds
TIMEDIFF() Subtract time
TIMESTAMP() With a single argument, this function returns the date or datetime expression; with two arguments, the sum of the arguments
TIMESTAMPADD() Add an interval to a datetime expression
TIMESTAMPDIFF() Subtract an interval from a datetime expression
TO_DAYS() Return the date argument converted to days
TO_SECONDS() Return the date or datetime argument converted to seconds since Year 0
UNIX_TIMESTAMP() Return a Unix timestamp
UTC_DATE() Return the current UTC date
UTC_TIME() Return the current UTC time
UTC_TIMESTAMP() Return the current UTC date and time
WEEK() Return the week number
WEEKDAY() Return the weekday index
WEEKOFYEAR() Return the calendar week of the date (1-53)
YEAR() Return the year
YEARWEEK() Return the year and week

참고

https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_adddate

 

MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions

12.7 Date and Time Functions This section describes the functions that can be used to manipulate temporal values. See Section 11.2, “Date and Time Data Types”, for a description of the range of values each date and time type has and the valid formats

dev.mysql.com

조건

flask 환경에서 in 을 사용하여 검색

방법

flask에서 변수를 받을때 리스트 형태( getlist('ip_group[]' )로 받음

sql 쿼리에 매개변수 전달 시, 리스트 형태를 전달

[html]

<select class="select2" multiple="multiple" name="ip_group[]" id="ip_group" />
  <option value="127.0.0.1">127.0.0.1</option>
  <option value="127.0.0.2">127.0.0.2</option>
</select>


[js]

var ip_group = $('#ip_group').val();

$.ajax({
        url:'/project/server_info',
        type:'POST',
        data: {ip_group:ip_group},
        success: function(data){
           showAlert('Server Info', data.info, 2, 2000);
       }     


[python + flask]

@project_blueprint.route('project/server_info', methods=['POST'])
@login_required
def project_server_info():
    ip_group = request.form.getlist('ip_group[]')
    
    ql = text('select a, b, c, d, e from tblServer where ip in :ip_group')
    connection = db.session.connection()
    results = db.engine.execute(sql, ip_group=ip_group)
    
    if results != None:
        details = []
        
        for r in results:
            details.append(r[0])
            details.append(r[1])
            details.append(r[2])
            details.append(r[3])
            details.append(r[4])
            
        return jsonify(details=details)

참고

https://stackoverflow.com/questions/8603088/sqlalchemy-in-clause

문제

MySQL의 like 조건에서 \가 포함된 경우 원하는 형태로 조회가 되지 않음

해결

조건

title 컬럼의 \m가 포함된 형태로 검색 ( 검색 내용에 \ 가 포함 )

1. \를 두개 더 붙인다

where title like '%\\\m%'


2. escape를 사용
   기본적으로 escape가 \로 설정되어 있음. 이걸 다른 문자로 변경(예제는 | 를 사용)

where title like '%|m%' escape '|'

참고

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=leokevin&logNo=220645049628


to Top