ubuntu设置asterisk开机启动遇到的问题

本文介绍了解决Asterisk服务启动时遇到的权限问题。通过调整/var/run/asterisk/asterisk.ctl文件的权限设置为777,确保了asterisk服务能够正常启动并运行。

   为了省事 asterisk 启动命令直接放到了 /etc/init.d/rc.local 里,

开机启动后,用命令 ps -e|grep asterisk 能看到 asterisk服务启动了

但是 asterisk -r  无法连接,会报 错:

Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
最后 在rc.local 里加了这样的一句命令:

chmod 777 /var/run/asterisk/asterisk.ctl

解决了问题,

很奇怪 为什么 放到启动命令里会出现权限问题

asterisk整个目录 都已经开发了权限

asterisk.ctl 文件是 服务启动后生成的,

我查看了一下权限是这样的

srwxr-xr-x 1 root root 0 2012-12-17 09:23 asterisk.ctl
很奇怪 在命令窗口敲命令 和 开机自动启动有什么不同呢

// filename lock-1.c (1)编辑如下程序 more lock-1.c #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/file.h> #include <wait.h> #define PATH "/tmp/lock" int main() 22 { int fd; pid_t pid; fd = open(PATH, O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) { perror("open()"); exit(1); } if (flock(fd, LOCK_EX) < 0) { perror("flock()"); exit(1); } printf("%d: locked!\n", getpid()); pid = fork(); if (pid < 0) { perror("fork()"); exit(1); } if (pid == 0) { /* fd = open(PATH, O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) { perror("open()"); exit(1); } */ if (flock(fd, LOCK_EX) < 0) { perror("flock()"); exit(1); } printf("%d: locked!\n", getpid()); exit(0); } wait(NULL); unlink(PATH); sleep(10); exit(0); } (2)# gcc lock-1.c -o lock-1 ## 编译 # ./lock-1& ## 运行,可能的结果如下:(并未达到锁的目的) 23 [wys@ai codes]$ 2854628: locked! 2854629: locked! [wys@ai codes]$ lslocks|grep lock lock-1 2855077 FLOCK WRITE 0 0 0 /tmp/lock (deleted) ### man lslocks #查看 lslocks 手册 COMMAND The command name of the process holding the lock. PID The process ID of the process which holds the lock or -1 for OFDLCK. TYPE The type of lock; can be FLOCK (created with flock(2)), POSIX (created with fcntl(2) and lockf(3)) or OFDLCK (created with fcntl(2). SIZE Size of the locked file. MODE The lock's access permissions (read, write). If the process is blocked and waiting for the lock, then the mode is postfixed with an '*' (asterisk). M Whether the lock is mandatory; 0 means no (meaning the lock is only advisory), 1 means yes. (See fcntl(2).) START Relative byte offset of the lock. END Ending offset of the lock. PATH Full path of the lock. If none is found, or there are no permissions to read the path, it will fall back to the device's mountpoint and "..." is appended to the path. The path might be truncated; use --notruncate to get the full path. BLOCKER The PID of the process which blocks the lock. [wys@ai codes]$ ./lock-1& [wys@ai codes]$ 2940080: locked! 2940081: locked! [wys@ai codes]$ cat /proc/locks |grep 2940080 41: FLOCK ADVISORY WRITE 2940080 00:22:127297 0 EOF ### man proc ## 可查看/proc/locks 的手册 /proc/locks This file shows current file locks (flock(2) and fcntl(2)) and leases (fcntl(2)). An example of the content shown in this file is the following: 1: POSIX ADVISORY READ 5433 08:01:7864448 128 128 2: FLOCK ADVISORY WRITE 2001 08:01:7864554 0 EOF (1) The ordinal position of the lock in the list. (2) The lock type. Values that may appear here include: FLOCK This is a BSD file lock created using flock(2). OFDLCK This is an open file description (OFD) lock created using fcntl(2). POSIX This is a POSIX byte-range lock created using fcntl(2). (3) Among the strings that can appear here are the following: ADVISORY This is an advisory lock. MANDATORY This is a mandatory lock. (4) The type of lock. Values that can appear here are: READ This is a POSIX or OFD read lock, or a BSD shared lock. 24 WRITE This is a POSIX or OFD write lock, or a BSD exclusive lock. (5) The PID of the process that owns the lock. (6) Three colon-separated subfields that identify the major and minor device ID of the device containing the filesystem where the locked file resides, followed by the inode number of the locked file. (7) The byte offset of the first byte of the lock. For BSD locks, this value is always 0. (8) The byte offset of the last byte of the lock. EOF in this field means that the lock extends to the end of the file. For BSD locks, the value shown is always EOF. 这是Linux老师布置的实验 这是实验指导书的第一二步 我应该如何操作才能完成老师的任务
11-08
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值