- แสดงความคิดเห็น
- อ่าน 2273 ครั้ง
- not spam ()


ที่ใช้ๆกันทั่วไปมักจะเป็น
shutdown -h now
หรือ
poweroff ครับขึ้นอยู่กับใช้ตระกูลไหนครับ
รบกวนผู้รู้แจ้ง...เพิ่มเติมด้วยครับ

root#init0 แล้วกด Enter ครับ


localhost# halt ก็ปิดได้ครับ
localhost# shutdown -h now ก็ปิดได้ครับ
สุดท้าย ถ้าเป็นเครื่องรุ่นใหม่หน่อย กดปุ่ม power ระบบจะทำการ Shutdown เองครับ (อันนี้ใช้บ่อยขี้เกียจพิมพ์)

ถ้าเป็นเครื่องรุ่นหลังๆ มาเนี่ย (2-3 ปีมาเนี่ย) ก็กดปุ่ม Power เืพื่อเปิด และปิดเครื่องได้เลยครับ ไม่ต้องเรียนรู้คำสั่งอะไร ไม่ต้องต่อ จอ Keyboard Mouse ไงครับ
ง่ายๆ สมกับเป็น Simple Internet Server ไม้ครับ

ผมใช้ Windows 2003 R2 c:/>shutdown -s -t 0
2003 R2 ทำ Streaming ภาพพร้อมเสียง ในรูปแบบ mms://192.168.2.2/ช่องสัญญาณ
- จัดรายการวิทยุ
- ถ่ายทอดสดกิจกรรม
- ทำรายการออนไลน์
--------------------------------------------------------------------------------------------
SIS จะทำได้ไหมครับ รบกวนแนะนำด้วย


root#poweroff กด enter

ขออีกนิด shutdown auto ตอน 22.00
ทำงัยครับรบกวนช่วย อธิบาย/etc/cron.d,/etc/cron.daily
ผมเขียนอย่างนี้ใช้งานใด้ไหม?
#!/bin/sh
0 22 * * * /root shutdown -NOW -h
ในสคริปต์ 22down แล้วลิ้งไป /etc/cron.daily
ช่วยแนะนำวิที่ทีถูกต้องด้วยครับ

เข้าใจว่าคุณคงสับสนระหว่างการเขียน Script กับการกำหนดในไฟล์ /etc/crontab
ที่ขึ้นต้นว่า #!/bin/sh นั่นสำหรับเขียน Script ครับแต่บรรทัดต่อมาของคุณมันทำงานไม่ได้แน่ๆ เพราะไม่ใช่ Script คำสั่งครับ แต่เป็ยบรรทัดกำหนดใน crontab ครับ
ให้เอาบรรทัดนั้นไปใส่เพิ่มในไฟล์ /etc/crontab ครับ แก้ไข -NOW ให้เป็น -now (ตัวเล็กหมด) ด้วยนะครับ แล้วก็ root ไม่ได้มี "/" ครับ ตรงนั้นเป็นการระบุว่าทำงานด้วย User ใด จึงให้เป็น root เฉยๆ ครับ

shutdown -h 22:00 ผมใช้คำสั่งนี้ ที่ Terminal เครื่องทำงาน
แต่ใช้ 59 21 * * * nop /sbin/shutdown -h 22:00
ที่ crontab เครื่องไม่ยอมปิดครับดูตรงไหนดี
ขอบคุณล่วงหน้าครับ


nop@nop-desktop:~$ sudo shutdown -h -now
shutdown: invalid option: -o
Try `shutdown --help' for more information.
nop@nop-desktop:~$ sudo shutdown -h 22:00
[sudo] password for nop:
Broadcast message from nop@nop-desktop
(/dev/pts/0) at 5:45 ...
The system is going down for halt in 975 minutes!
แต่เครื่อง server nop=root
ทำไหมผมใช้ shutdown -h -now ไม่ใด้ครับ


แต่เครื่อง server nop=root
ทำไหมผมใช้ shutdown -h -now ไม่ใด้ครับ
เป็นอย่างไร หรือทำอย่างไรครับ nop=root เนี่ยครับ :)

ผมเดาเอาว่า เขาคงกำหนด alias nop=root ไว้กระมัง?!?
แต่ก็งงๆ ว่า ถ้าถึงกับกำหนด alsias ใน Environment เป็น ก็ไม่น่าตกม้าตายกับการกำหนด Shutdown ใน Corn

อ้อ โทษครับ"nop"user แรกทีเข้าเครื่องตอนล็อกออน แล้วผมไปจัดให้อยู่ในกล่มเดียวกับ"root"
ผมจะเช็คดูตรงไหนใด้ครับว่า "alias nop=root"หรือเปล่า และ "crontab"ทำงามตามที่เราตั้งใว้
ผม ps -A
nop@fac:~$ ps -A
PID TTY TIME CMD
----------- ------------ ------------
5032 ? 00:00:00 krfcommd
5067 ? 00:00:00 atd
5081 ? 00:00:00 cron
5133 ? 00:00:00 apache2
5198 ? 00:00:00 apache2
5199 ? 00:00:00 apache2
5200 ? 00:00:00 apache2
5201 ? 00:00:00 apache2
5202 ? 00:00:00 apache2
5353 ? 00:00:00 cupsd
5728 ? 00:00:00 apache2
5738 ? 00:00:03 smbd
5742 ? 00:00:00 smbd
5743 ? 00:00:08 smbd
5746 ? 00:00:00 smbd
5767 ? 00:00:16 smbd
5776 ? 00:00:03 smbd
5777 ? 00:00:10 smbd
5796 ? 00:00:04 smbd
5852 ? 00:00:00 smbd
-------- - -----------------------
7255 ? 00:00:00 sshd
7263 ? 00:00:00 sshd
7264 pts/0 00:00:00 bash
8196 pts/0 00:00:00 ps
เห็นมีแต่"cron"ที่ pit 5081"shutdown"ไม่มี เปลี่ยนเวลาไหม่ก็ไม่ทำงาน
สงสัยคำสั่งพิด ผมไปแก้ที่ /etc/sudoers เพิ่มบรรทัด nop ALL=NOPASSWD:/sbin/shutdown
ที่file /etc/crontab
# m h dom mon dow command
35 14 * * * nop sudo /sbin/shutdown -h 22:00
งานนี้ตกม้าตายเนียนเลยครับ งงมากๆๆ

จะเอา 4 ทุ่มใช่ไหมครับ? ลองไปใส่แค่นี้ดูนะครับ
0 22 * * * root /sbin/shutdown -h now

nop@nop-desktop:~$ sudo crontab -u root -l
# m h dom mon dow command
25 19 * * * root /sbin/shutdown -h now
nop@nop-desktop:~$ date
Fri Jul 25 19:21:30 ICT 2008
nop@nop-desktop:~$ sudo crontab -u root -l
# m h dom mon dow command
25 19 * * * root /sbin/shutdown -h now
nop@nop-desktop:~$ date
Fri Jul 25 19:21:30 ICT 2008
nop@nop-desktop:
ที่ syslog มีข้อคามดังนี้
Jul 25 19:21:20 nop-desktop crontab[5814]: (root) REPLACE (root)
Jul 25 19:21:20 nop-desktop crontab[5814]: (root) END EDIT (root)
Jul 25 19:21:23 nop-desktop crontab[5817]: (root) LIST (root)
Jul 25 19:22:01 nop-desktop /usr/sbin/cron[5372]: (root) RELOAD (crontabs/root)
Jul 25 19:25:01 nop-desktop /USR/SBIN/CRON[5857]: (root) CMD (root /sbin/shutdown -h now)
Jul 25 19:37:05 nop-desktop -- MARK --
Jul 25 19:53:44 nop-desktop crontab[5885]: (root) LIST (root)
Jul 25 19:53:49 nop-desktop crontab[5886]: (root) BEGIN EDIT (root)
Jul 25 19:54:19 nop-desktop crontab[5886]: (root) REPLACE (root)
Jul 25 19:54:19 nop-desktop crontab[5886]: (root) END EDIT (root)
Jul 25 19:54:23 nop-desktop crontab[5889]: (root) LIST (root)
Jul 25 19:55:01 nop-desktop /usr/sbin/cron[5372]: (root) RELOAD (crontabs/root)
Jul 25 20:00:27 nop-desktop kernel: [ 1200.734873] printk: 21 messages suppressed
ไม่ทราบผิดตรงไหน เครื่องถึงไม่shutdown
ขอบคุณล่วงหน้าครับ


# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # ดูแบบนี้หรือเปล่า
ตอนแก้ไข่ทำแบบนี้
nop@nop-desktop:~$ sudo crontab -u root -e
25 19 * * * root /sbin/shutdown -h now
# m h dom mon dow command
![]()

อ๋า... มันไม่เข้านี่
เอาบรรทัด
0 22 * * * root /sbin/shutdown -h now
ไปใส่ใน /etc/crontab นะครับ ให้เป็น ....
# m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0 22 * * * root /sbin/shutdown -h now #
ทีนี้ได้แน่นอน

แก้ไข ตามนี้ใช้ใด้แล้วครับ
ไปใส่ใน /etc/crontab นะครับ ให้เป็น ....
# m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
พจดี ผมไปแก้ไขโดยใช้ตาม "web"ทีมีการอธิบาย การใช้crontab
โดยคำสั่ง sudo crontab -u root -e ใช้ -lดูมันก็
0 22 * * * root /sbin/shutdown -h now ไม่รูมันไปเอามาจากไหน
ให้ผมดู งานนี้หมดม้าเป็นคอกเอยครับ ขอบคุณอีกครั้งครับ
อรุช อุดล