Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: crontab -e crond

  1. #1
    Senior Member
    Join Date
    Jul 2011
    Posts
    110

    crontab -e crond

    Can someone advise as to how I can add a job that shut down the pc after being booted to the remasterd dvd (6.7) I place the dvd in the optical drive and have lab pcs boot to that disk. I would like to have the remastered dvd have a job/script that will shutdown the pc say at 5 PM. I opened terminal and attampted to schedule using crontab -e via knoppix console and root. Both appeared to have no affect. Thanks for help and advice.

  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Hi itman,

    First you have to start cron with the following command:

    Code:
    sudo service cron start
    After this, your scheduled tasks should run.

  3. #3
    Senior Member
    Join Date
    Jul 2011
    Posts
    110
    Thanks lapidu for that info. I feel that this would work fine but someone must enter that command each time the pc booted from the dvd/cd? I need to be bale to save or have that cron service start within the remastered environment so that each remaster would do this automatically. Your ideas? Thanks

  4. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    You have these options:

    1) You mentioned the DVD you're booting is remastered. Why not enable cron by default in your remastered version?

    2) Use persistent store. It will keep cron running once started. (Someone please correct me if I'm wrong about this).

    3) Use knoppix.sh

  5. #5
    Senior Member
    Join Date
    Jul 2011
    Posts
    110
    I assume that should work. I will test to verify and post back here. Im a little stuck on the enable cron by default that you mention. I assume I can start cron within my persistent install and it will be syncd with my changes during remaster? Or do you mean enable it some other manor?

  6. #6
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Enabling cron by default should be possible by adding an entry to the appropriate script. I see that there is an entry in /etc/rc.local to start the cups service. I presume, but have not tested, that adding cron to that same file in a remastered version will thereafter ensure default starting of cron at boot. But I have cause for doubt after reading section 11.6 of the Debian FAQ - does the same apply to Knoppix, I wonder?. Perhaps you can run some tests and let us know, or someone with definitive knowledge will chime in.

    Try starting cron within your persistent install and rebooting, then check whether cron remains running (for example, by scheduling a command and seeing whether it executes). If persistence keeps cron running, then your synchronised remaster will probably do the same.

  7. #7
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    Quote Originally Posted by lapidu View Post
    Enabling cron by default should be possible by adding an entry to the appropriate script. I see that there is an entry in /etc/rc.local to start the cups service. I presume, but have not tested, that adding cron to that same file in a remastered version will thereafter ensure default starting of cron at boot. But I have cause for doubt after reading section 11.6 of the Debian FAQ - does the same apply to Knoppix, I wonder?. Perhaps you can run some tests and let us know, or someone with definitive knowledge will chime in.

    Try starting cron within your persistent install and rebooting, then check whether cron remains running (for example, by scheduling a command and seeing whether it executes). If persistence keeps cron running, then your synchronised remaster will probably do the same.
    Yes, adding "cron" to the services listing in /etc/rc.local is probably the best, and "Standard knoppix" way to get it going. Cups is already on the list, and I have, for example, added vmware services. And either using persistent store or hard-wiring it into a remaster, will keep it up. I haven't checked if there is an exception for cron - think that would be strange.

    Because cron is a standard system service that actually should be up and running, I think it is better to start it from /etc/rc.local than from knoppix.sh.

    As for persistence, the best is to run from USB or hard disk partition KNOPPIX copy. Normally, DC/DVD would, at worst, be used only for booting.

    The standard way of setting up user's crontab is very user-friendly - if you are a skilled vi/vim user
    Otherwise it will often feel like a hassle, I think. But use the standard way:

    Code:
     
    crontab -e
    will set you up to vi-edit your crontab file. (The key sequence ESC :wq will write to file and exit, if there is an error in time setup, you will be asked to correct it.)

    I haven't tried, but su-commands ought to be executable there. I try to avoid editing the system-wide /etc/crontab whenever possible, because screwing up that may in some cases produce serious problems.

    Among usual cronjobs are different kinds of system backups prominent.

  8. #8
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    Update: Tried sudo shutdown and suhutdown in root's crontab file, in
    /var/spool/cron/crontabs

    System won't shut down that direct way, it seems. Not indirectly, either?
    Scripts are being run, so cron is at work.

  9. #9
    Senior Member registered user
    Join Date
    Feb 2010
    Posts
    512
    Greetings Capricorny!

    Have you tried a line like
    Code:
    50 15 * * * /sbin/shutdown -h now
    It worked on my system using Knoppix 7.0.3 CD.

  10. #10
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    The standard way of setting up user's crontab is very user-friendly - if you are a skilled vi/vim user
    Yes, surely I speak for quite a few of us when I say that developing our vim skills is on the to-do list! Interesting story behind the development of vi for anyone curious about why it seems so unusual to operate, search it up if you like.

    Until then, here are some commands that will allow you to use another editor by default from your terminal when editing crontabs:

    Code:
    export EDITOR=nano    # Will make, e.g., nano the default editor until that shell is closed.
    
    
    update-alternatives --config editor      # Will retain your selection system-wide.
    As for certain commands not executing, klaus2008's solution will work; the full path of any executable is needed for user and root crontab because the path line, e.g....

    Code:
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    ...does not appear in them by default. You can, however, append the above PATH line to your user/root crontabs, and at the top of any scripts you wish to call via cron, instead of specifying full paths for each command separately. This has the advantage of increasing script portability across systems where the default path for executables might change, which case would necessitate lots of line-by-line updating of your script. The system-wide crontab specifies both shell and path.

Page 1 of 2 12 LastLast

Posting Permissions

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


SanDisk 128GB Ultra Flair USB 3.0 Flash Drive - SDCZ73-128G-G46 picture

SanDisk 128GB Ultra Flair USB 3.0 Flash Drive - SDCZ73-128G-G46

$12.99



iDiskk MFI USB Flash Drive iPhone Photo Storage Stick for iPhone iPad Android picture

iDiskk MFI USB Flash Drive iPhone Photo Storage Stick for iPhone iPad Android

$97.59



512GB  USB Flash Drive External Storage Memory Stick For iPhone iPad Android picture

512GB USB Flash Drive External Storage Memory Stick For iPhone iPad Android

$17.59



SanDisk 128GB Ultra Dual Drive USB Type-C, USB 3.1 Flash Drive - SDDDC2-032G-G46 picture

SanDisk 128GB Ultra Dual Drive USB Type-C, USB 3.1 Flash Drive - SDDDC2-032G-G46

$10.99



Sandisk 16GB 32GB 64GB 128GB Cruzer Blade Flash Drive Memory Stick USB Lot Pack picture

Sandisk 16GB 32GB 64GB 128GB Cruzer Blade Flash Drive Memory Stick USB Lot Pack

$4.99



2TB USB 3.0 Flash Drive Memory Photo Stick for iPhone Android iPad Type C 3 IN1 picture

2TB USB 3.0 Flash Drive Memory Photo Stick for iPhone Android iPad Type C 3 IN1

$16.72



Mechanical Style Flash Drive USB 3.0 High Speed 16TB Large Capacity Waterproof  picture

Mechanical Style Flash Drive USB 3.0 High Speed 16TB Large Capacity Waterproof

$13.09



USB 3.0 Flash Drive 32GB 64GB 128GB Memory Stick Thumb Stick Lot Pack picture

USB 3.0 Flash Drive 32GB 64GB 128GB Memory Stick Thumb Stick Lot Pack

$379.99



1TB/2TB USB 3.0 Flash Drive Thumb U Disk Memory Stick Pen PC Laptop Storage lot picture

1TB/2TB USB 3.0 Flash Drive Thumb U Disk Memory Stick Pen PC Laptop Storage lot

$388.39



USB Flash Drive Memory Stick Pendrive Thumb Drive 4GB, 8GB, 32GB, 64GB 128GB LOT picture

USB Flash Drive Memory Stick Pendrive Thumb Drive 4GB, 8GB, 32GB, 64GB 128GB LOT

$259.34