Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: crontab -e crond

  1. #11
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    Thanks a lot to klaus2008 and lapidu!

    I think you have given excellent instructions. One reason I didn't mention the alternative editor setup, is that unless one is very adept at another editor, like nano, it may be just as smart to use the vi/vim default. In practice, it will always be available on a system, but, for example, my own standard editor, emacs, will not.

    I will also advise to use your user's crontab whenever possible.

    Summing up

    1. Edit /etc/rc.local

    Code:
    SERVICES="cups cron"
    
    for i in $SERVICES; do
     [ -x /etc/init.d/"$i" ] && /etc/init.d/"$i" start >/dev/null 2>&1
    done
    2. Edit user's crontab to include shell and PATH, you may copy from /etc/crontab. This works for me to auto-shutdown at 17.00 every day:

    Code:
    #
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    # m h  dom mon dow   command
    0 17 *    *    *      sudo shutdown -h now
    3. To test the setup, I find Qemu very useful. I have several grub-bootable Poor Man's Installs on the main harddisk, so I use

    Code:
    sudo modprobe kvm && sudo modprobe kvm-intel
    sudo qemu -machine accel=kvm -hda /dev/sda -m 2047 &
    and just pick up one alternative to test. Be a bit careful during testing - I set it up to shutdown every third minute, and I barely managed to edit that to something else before the system went down (Could of course have mounted the persistent image "off-line".)

    4. As for the original problem posted, I must say that I will, generally, advise against remastering a DVD with hard-wired shutdown at 5 o'clock - now that we know it works . For example, the computer's clock may not always be set correctly. I think it is way better to use persistent store on USB sticks for that, and just boot from DVD when necessary. But if there are, for example, special safety concerns, it can of course be done.

  2. #12
    Senior Member
    Join Date
    Jul 2011
    Posts
    110
    I have failed so far at the attempt to get the persistent installation to shutdown at scheduled time. rc.local now starts cron upon boot properly but /etc/crontab doesnt reboot the pc at time I specify. I have configured it to shutdown at 10 AM but the unit has not shut down.
    My /etc/crontab file contains the below:

    # /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
    00 10 * * * sudo shutdown -h now
    #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 )


    Please advise if anyone sees the problem here. Keep in mind this Knoppix 6.7

  3. #13
    Moderator Moderator
    Join Date
    Nov 2010
    Location
    Germany/ Dietzenbach
    Posts
    1,124
    Only root has permission for "shutdown"; therefore start with "crontab -e" in a root-terminal and use
    Code:
    00 10 *    *    * /sbin/shutdown -h now

  4. #14
    Senior Member
    Join Date
    Jul 2011
    Posts
    110
    This is issue is resolved. Thanks for everyone's input. For those whom wish to schedule a shutdown in Knoppix 6.7 you must add the word cron to the /etc/rc.local as seen in the sample below. Then edit your /etc/crontab to add a line such as mine, 0 10 * * * root /sbin/shutdown -h now Which will shutdown at 10AM using the user root.


    #!/bin/bash
    #
    # rc.local
    #
    # Start local services after hardware detection

    SERVICES="cups cron"

    for i in $SERVICES; do
    [ -x /etc/init.d/"$i" ] && /etc/init.d/"$i" start >/dev/null 2>&1
    done

    exit 0

  5. #15
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    The method summarized in #11 works. Personally, I would stay away from /etc/crontab for this, as user's crontab, with shell and path specifications, works just fine. No need for root either,
    If there are several different users on the system, using /etc/crontab may help coordinate different cronjobs. If there is just one or two, user's crontab should be good enough. Intimidating as it may be, I have found it useful for me to stick with crontab -e --- for several reasons, among them that some time definition errors will be caught that way.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge R730 2x E5-2699V3 2.3Ghz 36 Core 128GB RAM H730 X520-I350 2x750W picture

Dell PowerEdge R730 2x E5-2699V3 2.3Ghz 36 Core 128GB RAM H730 X520-I350 2x750W

$329.99



Dell Poweredge R630 Server 2x E5-2620 V4 =16 Cores | S130 | 32GB RAM | 2x trays picture

Dell Poweredge R630 Server 2x E5-2620 V4 =16 Cores | S130 | 32GB RAM | 2x trays

$159.99



DELL R630 SERVER 8 x 2.5'' 2X E5-2680V4 32GB RAM IDRAC ENT & NDC 2X 495W PSU picture

DELL R630 SERVER 8 x 2.5'' 2X E5-2680V4 32GB RAM IDRAC ENT & NDC 2X 495W PSU

$169.95



Dell PowerEdge R630 Server 2x E5-2640v3 2.60Ghz 16-Core 64GB H330 picture

Dell PowerEdge R630 Server 2x E5-2640v3 2.60Ghz 16-Core 64GB H330

$182.65



Dell PowerEdge R710 2.5

Dell PowerEdge R710 2.5" 2U Server 2x X5670 2.93GHZ 12-Core 128gb 2x 1TB SAS

$114.99



Dell PowerEdge T420 2x Xeon E5-2430 V2 2.50GHZ 32GB DDR3-1600MHZ 2x 550W PSU picture

Dell PowerEdge T420 2x Xeon E5-2430 V2 2.50GHZ 32GB DDR3-1600MHZ 2x 550W PSU

$149.95



Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD picture

Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD

$389.99



Dell PowerEdge R630 Server 2x E5-2680 V4 = 28 Cores S130 32GB RAM NEW 480GB SSD picture

Dell PowerEdge R630 Server 2x E5-2680 V4 = 28 Cores S130 32GB RAM NEW 480GB SSD

$197.99



DELL PowerEdge R730 Server 2x E5-2697v4 2.3GHz =36 Cores 128GB H730 4xRJ45 picture

DELL PowerEdge R730 Server 2x E5-2697v4 2.3GHz =36 Cores 128GB H730 4xRJ45

$461.00



Dell Poweredge R440 2x Xeon Silver 4110 SR3GH 32GB RAM No Drives Server picture

Dell Poweredge R440 2x Xeon Silver 4110 SR3GH 32GB RAM No Drives Server

$349.99