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
  •  


IBM Power S822 8284-22A 12SFF Power8 3.89GHz 6Core 64GB RAM No HDD Server System picture

IBM Power S822 8284-22A 12SFF Power8 3.89GHz 6Core 64GB RAM No HDD Server System

$359.99



IBM Netezza 3567 picture

IBM Netezza 3567

$4750.00



IBM x3650 M4 2x Xeon E5-2670 2.6ghz 16-Core / 64GB / M5110e / 2x PSU picture

IBM x3650 M4 2x Xeon E5-2670 2.6ghz 16-Core / 64GB / M5110e / 2x PSU

$229.99



IBM System X 3250 M5 Single Xeon Quad Core E3-1220 v3 @3.1GHz,8GB RAM,Linux SUSE picture

IBM System X 3250 M5 Single Xeon Quad Core E3-1220 v3 @3.1GHz,8GB RAM,Linux SUSE

$159.00



IBM System x3550 M3 Dual Intel Xeon X5650 @2.67GHz 32GB RAM No HDD picture

IBM System x3550 M3 Dual Intel Xeon X5650 @2.67GHz 32GB RAM No HDD

$74.50



ibm server z series picture

ibm server z series

$16000.00



IBM Cloud Object Storage Slicestor 2448 E5-2637 3.5Ghz 128GB DDR4 - NO HDD - NEW picture

IBM Cloud Object Storage Slicestor 2448 E5-2637 3.5Ghz 128GB DDR4 - NO HDD - NEW

$399.00



IBM mainframe server cpu IBM93 vintage cpu collector's item picture

IBM mainframe server cpu IBM93 vintage cpu collector's item

$125.99



IBM QRadar XX28-C 2U Server BOOTS 2x Xeon E5-2650 v3 2.3GHz 128GB RAM NO HDDs picture

IBM QRadar XX28-C 2U Server BOOTS 2x Xeon E5-2650 v3 2.3GHz 128GB RAM NO HDDs

$249.99



IBM X3850 M2 4U Rack Server BOOTS 4x Xeon MP 2.93Ghz Hot Swap 32GB RAM NO HDDs picture

IBM X3850 M2 4U Rack Server BOOTS 4x Xeon MP 2.93Ghz Hot Swap 32GB RAM NO HDDs

$279.99