我想在启动带有redhat的linux服务器的过程中运行一个shell脚本.
以下是我为实现这一目标而采取的步骤
1)我创建了脚本/home/user/script/test.sh
#!/bin/bash
echo "xyz" >> output
Run Code Online (Sandbox Code Playgroud)
2)我使用下面的命令将脚本文件作为可执行文件
chmod +x /home/user/script/test.sh
Run Code Online (Sandbox Code Playgroud)
3)我test.sh在/etc/init.d目录中创建了put 文件
4)我使用下面的命令做了软链接
ls -s /etc/init.d/test.sh /etc/rc.d/S15test.sh
Run Code Online (Sandbox Code Playgroud)
5)重启服务器
我尝试过的另一件事就是放在/etc/rc.local文件下面
/bin/sh /home/user/script/test.sh
Run Code Online (Sandbox Code Playgroud)
但我仍然无法执行test.sh文件内部编写的代码.
我想从日期“01-01-9999”的 oracle 的日期字段中获取毫秒数。
我创建了下面的块来实现相同的目的。
set serveroutput on;
declare
base_point constant timestamp := to_timestamp_tz('01-JAN-1970 00:00:00.000+00:00', 'DD-Mon-RR HH24:MI:SS.FFTZH:TZM') AT TIME ZONE 'UTC';
now timestamp := to_timestamp_tz('01-01-2099 00:00:00.000+00:00', 'DD-MM-RR HH24:MI:SS.FFTZH:TZM') AT TIME ZONE 'UTC';
-- now constant timestamp := systimestamp AT TIME ZONE 'UTC' ;
n number;
begin
select to_timestamp_tz(to_char(todate,'DD-MM-YY HH24:MI:SS')||'.000+00:00','DD-MM-YY HH24:MI:SS.FFTZH:TZM')
into now
from t_table where ACCOUNTID = 'ACC001124211';
DBMS_OUTPUT.put_line(' now :'||now);
n := (
((extract(day from (now-base_point)))*86400)
+ ((extract(hour from (now-base_point)))*3600)
+ ((extract(minute from (now-base_point)))*60)
+ ((extract(second from (now-base_point))))
) * …Run Code Online (Sandbox Code Playgroud)