Fail to save a Cron job (SOLVED)

I can't save a new cron job in my system. I use
crontab -e
or
export VISUAL=gedit && crontab -e
to add a new job. These commands open a /tmp/crontab.XXXX file that after saving, cron jobs are NOT updated!
It's too strange to me* !
I run
nano -w /var/spool/cron/root
and the cron job is listed now by
crontab -l
Why I can't save cron jobs directly from crontab -e?
( I have read the vi man pages :-) )
* I am newbie, just one month Linux user with 3 distro succesfully installed

osigen wrote:Ooops! VI is complicated editor.
Thanks anyway!
Its a great editor once you learn to use it 
here's some usesfull documentation on the commands:
http://www.fprintf.net/vimCheatSheet.html

Similar Messages

  • [Solved] Setting Up A Cron Job

    I want to set up a cron job that will copy (update) my download folder that contains all my linux related stuff to the linux downloads folder contained in my windows downloads folder. I know how to set up crontab but vi(m) confuses me since it opens crontab as a temp file and I dont know what to call it when I try and save it. I tried using EDITOR=nano crontab -e but it still opens vim
    heres the line I want to input into crontab:
    0 3 * * * cp -Ru /home/bran/downloads/* "/media/mybook/Downloads/Linux Downloads/"
    Last edited by brando56894 (2009-05-05 23:12:05)

    I tried adding the job to /etc/cron.daily but that didnt seem to have any effect on anything, ive been learning vim on and off for awhile now but its alot to learn and its completely different than anything else. I know the basic stuff (save, quit, quit!, startinsert) but thats about it. I think the best feature I love about it is the syntax highlighting since i usually use nano and it doesnt seem to work even when i tried to enable it in the config file.
    brisbin33 wrote:
    hey, that was my bad.  i guess it's a preference that i incorrectly characterized as a best practice.  too much bash scripting makes me aware of when things don't _need_ to be double quoted... doesn't mean they _shouldn't_ be double quoted. 
    getting into that habit of the down slash in front of spaces might come in handy though b/c you would know to also put it in front of symbols like $ and ? which wouldn't behave well inside double quotes.  however, in your case, either way works just fine.
    i'll trade that bit of bum advice for some good advice though: look into rsync, it works very similar to cp except it won't spend all that time/energy copying files that are already there.  does my nightly backup (~205 GB) in less than 3 minutes.
    oh, and don't forget to add [solved] if you get this all working.
    haha its cool, i was actually thinking about using rsync originally but then i was looking up a guide for it and it seemed to complex to do something simple like I needed to do. my linux downloads folder is only about 400 or so mb and the u flag updates only changed files so it doesnt take that long anyway.

  • [Solved] Have Cron Job Open Terminal Window

    I want to run a ping script every morning to check the liveliness and latency of specific servers. The script itself works fine but I can't figure out how to have cron open up a terminal window so I can see the script running.
    This is what I have so far:
    #runs /home/bran/pingservers.sh everyday at 8:30 am
    10 10 * * * env DISPLAY=:0 konsole -e ~/pingservers.sh
    But it doesn't open anything I don't even know if the job is even executing.
    Last edited by brando56894 (2013-05-20 14:25:42)

    I am unsure how to get the script to open a terminal, but the journal should have some information on whether the script is running or not and if there are any errors.
    brando56894 wrote:
    I don't even think cron jobs are running at all. I changed my job to
    1 * * * * /bin/echo hello world
    and it hasn't done anything...
    As far as the job above, I just wanted to note that you have it set to run on the first minute of every hour. If you were looking for every second minute, you would want the following:
    */1 * * * * /foo/bar
    Last edited by BluMongoose (2013-05-14 22:01:48)

  • [SOLVED] Cron Job that starts every 30 minutes from boot

    I wish to have a cron job that runs a script every 30 minutes from boot, without any users logging in.
    I know about crontab -e, but I think that would I only run once i'm logged in. I've also heard about @reboot, but that would only run the script once.
    RabbidRabbit
    Last edited by rabbidrabbit (2012-01-31 20:14:13)

    Cron jobs will run whenever the system is up, regardless of whether or not anyone is logged in.
    I don't remember the syntax, but I know that at least some cron implementations have a way to run a job every 30 minutes, starting for the first time 30 minutes after reboot.
    EDIT: I just checked the syntax for fcron, which is what I use, and it seems like doing @ 30 your/command/here will make it run every 30 minutes of uptime.
    Last edited by kyla (2012-01-31 00:17:30)

  • [solved] Emacs fails to save to gpg encrypted files

    I have a few org-mode files encrypted to .gpg files with different keys. Each file bears the headers to tell emacs it's an org-mode file and which key to use to encrypt/decrypt:
    #-*- mode: org -*-
    #-*- epa-file-encrypt-to: ("[email protected]")
    This setup has been working flawlessly for years and  the keys are set to expire later in 2015.
    I noticed a couple days ago that emacs now fails to save those files: emacs works as expected while opening the files, i.e. pinentry-qt window shows up to ask for the passphrase, but when I tell it to save the file the following message is displayed in the minibuffer for a little while, then nothing and the file stays in its modified state. Last successful save dates from november 7th.
    (numeric values replaced because they look like gpg keys)
    Opening output file: [pub u 4096 1 <numeric value> <other numeric value> <another numeric value> nil u nil ...], 15
    The command epa-list-keys fails with Args out of range:
    command-execute: Symbol's function definition is void: \ epa-list-keys
    epg-list-keys: Args out of range: ["pub" "u" "4096" "1" "<numeric value>" "<other numeric value>" "<another numeric value>" nil "u" nil ...], 15
    I tracked this issue to this epg bug that supposed to be fixed since late november but obviously is not: http://debbugs.gnu.org/db/19/19002.html
    For those with the same issue, here's how to fix it:
    - uncompress epg.el.gz located in /usr/share/emacs/24.4/lisp
    - apply the below diff to epg.el
    - add write permission for regular user to epg.elc
    - run the byte-compile command from inside emacs on epg.el
    - remove write permission for regular user to epg.elc
    diff --git a/lisp/epg.el b/lisp/epg.el
    index 77181a1..4d9bbd2 100644
    --- a/lisp/epg.el
    +++ b/lisp/epg.el
    @@ -1910,8 +1910,9 @@ This function is for internal use only."
    string (match-string 0)
    index 0
    field 0)
    - (while (eq index
    - (string-match "\\([^:]+\\)?:" string index))
    + (while (and (< field (length (car keys)))
    + (eq index
    + (string-match "\\([^:]+\\)?:" string index)))
    (setq index (match-end 0))
    (aset (car keys) field (match-string 1 string))
    (setq field (1+ field))))
    http://git.savannah.gnu.org/cgit/emacs. … d=dbae12c5
    Last edited by kazimir (2014-12-13 13:55:43)

    looks good.
    See also. https://bbs.archlinux.org/viewtopic.php … 3#p1484413

  • Cron job status

    Hi All
    I had configured 1 cron job (in Unix and script is also in unix ) long back. But presently I don’t know this job is running or not? Please suggest how to look this cron job is running or not?
    Please help me out..
    Thanks,
    Siva

    Hello Siva
    ps -ef|grep cron
    If it won't work - try to look for your cron
    # crontab -l
    or the other solution :
    configure a mail for the scripts in the cron tab. hope this will solve your problem.
    # Purpose : To email to India, Hyderabad Backup Adminl
    if [ "$fbackup_status" = "0" ]
    then
    mail_file="/tmp/root/online.results"
    echo "Backup Completed Successfully, Return Code: $fbackup_status" >> $mail_file
    mt -f /dev/rmt/0m offline
    else
         if [ "$fbackup_status" = "4" ]
         then
              mail_file="/tmp/root/online.results"
              echo "Backup Completed with Warnings, Return Code: $fbackup_status" >> $mail_file
              mt -t /dev/rmt/0m offline
         else
              mail_file="/tmp/root/online.results"
              echo "\n Backup [ FAIL ], Return Code: $fbackup_status" >> $mail_file
         fi
    fi
    for mail in [email protected]
    do
    mailx -s "aperp1 Backup Report" $mail < $mail_file
    done
    # remember to include this in your script
    Cheers
    Ravi
    http://ravidba-oracle.blogspot.com/

  • How to take the cron job log in HP UX?

    Hi,
    How to take the cron job log in HP UX
    I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs?
    A. Cron service is required to run jobs and tasks such as backup.
    You must login as the root to run following commands. Each user that is using the cron service must have a cron configuration file in the /var/spool/cron/crontab directory. Also users are permitted if their name appeared in /var/adm/cron/cron.allow file
    Task: Find out if cron is running under HP-UX
    Type the following command at a shell prompt
    # ps -ef | grep cron
    Open /etc/rc.config.d/cron file
    vi /etc/rc.config.d/cron
    Set control variable to 1 to enable cron: CRON=1
    Set control variable to 0 to disable: CRON=0
    Close and save the file. To start or stop cron you can type the following command:
    # /sbin/init.d/cron start <-- start cron
    # /sbin/init.d/cron stop <-- stop cron
    Task: HP-UX Start cron service
    If cron is not running, simply type:
    # cron
    Task: Edit / create cron jobs
    Type the following command to submit a cron job:
    # crontab -e
    List your cron file:
    # crontab -l
    Backup all your cron jobs:
    # crontab -l > ~/backup.cron.jobs
    Remove ALL cron job:
    # crontab -r
    Task: Crontab file format
    Cron file format is as follows:
    MIN HOUR DATE MONTH DAY /PATH/TO/COMMAND
    0-59 0-23 1-31 1-12 0-6 /root/scripts/backup2tape.shEasy to remember crontab file format:
    * * * * * command to be executed
    | | | | |
    | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
    | | | ------- Month (1 - 12)
    | | --------- Day of month (1 - 31)
    | ----------- Hour (0 - 23)
    ------------- Minute (0 - 59)To run /root/script/backup at 23:00, every day, enter:
    # crontab -e
    Append following
    0 23 * * * /root/script/backupRun foo job very weekday (MON-Fri) at 6am, enter:
    0 6 * * 1-5 /root/script/backupFor more information refer to cron and crontab man pages.
    Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.
    Related Other Helpful FAQs:
    What is Cron?
    Linux Start and stop the cron or crond service
    Run crontab Every 10 Minutes
    Linux / UNIX Setup and run php script as a cron job
    Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot
    Discussion on This FAQDavid Says:
    January 15th, 2008 at 12:21 am
    You might note that all files normally found in /etc/init.d, /etc/rc*.d, and others are all in /sbin in HP-UX 10.20 and up.
    Note too that your formatting is off in the description of the /etc/rc.config.d/cron file. Also, if you run /usr/bin/cron instead of /sbin/init.d/cron start, the /etc/rc.config.d/cron file is not used.
    Regards,
    Satya

    I guess it would :)
    btw, how did this piece miss from the contents pasted by the OP ?
    The doc has given all details of CRON and missed where to see the logfiles. :)
    ****Added****
    I tried man crontab in windows, i dont see it.i overlook most of the things, i would have done the same ;)
    Edited by: Bobcatalog on Oct 23, 2008 9:40 AM

  • Need help with a cron job

    What I want to do is run an Applescript every 6 hours and 1 minute. If the computer is asleep when the job comes due, I want it to execute the script and reset the counter. Can crontab do this? If so, how to set it up?

    Gnarlodious wrote:
    Then skip it, I can see there is no easy way.
    I don't think it's that hard, though. Just a bit tricky. I was just a bit confused on what exactly you wanted.
    I could write a stay-open Applescript application, but I wanted to avoid cluttering up the Dock just to run a command every 6 hours.
    Nah, I wouldn't want that either.
    If I were doing something like this and I wanted it to work like this:
    1. Run every six hours, at 6 AM, noon, 6 PM, and midnight.
    2. Run after waking up if the computer has been asleep and missed any of the times in between, say if you let the computer sleep thru the 6 AM job.
    I'd do this:
    1. Call the AppleScript periodically from a cron job. How often would be dependent on how tight you want the times to be to when you wake up.
    2. Have the AppleScript save a text file somewhere with the time when it runs. That way, if your computer is asleep at 6 AM, the script could use this to decide if it missed running while it was asleep.
    3. Have your script check this time and if it's over 6 hours, let the script do its thing. If not, then just exit, to try all this again the next time cron runs it.
    Here's kind of a pseudo-code way of describing it:
    check if it's 6:01, 12:01, 18:01, 00:01
    if yes:
    do your AppleScript business
    save the current time in a file
    exit
    if it's not one of those times:
    check if it's been over 6 hours since the AppleScript did its business
    if yes:
    do the AppleScript business
    save the current time in a file
    exit
    if no:
    exit
    Then you could do two cron jobs:
    1 */6 * * * /path/to/applescript
    */5 * * * * /path/to/applescript
    The first one would run at your appointed times. The second would just run every 5 minutes to catch those times when the computer was asleep. The "5" could also be "10" for every ten minutes. Or whatever you decide you'd like.
    I'd show you an AppleScript, but I'm really not so good at that. If a Perl script would help, I could whip one up pretty quickly, I think.
    charlie

  • Mount USB/Firewire drive from shell or cron job

    Is there a way to mount a USB/Firewire drive from the shell or possibly mount it using a cron job? Here's the situation. I have a user that keeps all of her data on her desktop or in her Documents folder. I have attached a firewire drive to her PowerMac G5 (OS 10.4.6) and successfully created cron jobs to backup her entire user folder every night. The problem is that she logs off of her computer before she leaves work. When she logs of the firewire drive unmounts and the cron job fails because it cannot find the drive. I was hoping there was a way to mount the drive using a script so that it will mount, let the cron job run, and then possibly unmount the drive afterwards. Any help with this would be much appreciated.
    MacMini, PowerMac G5, iMac   Mac OS X (10.4.7)  

    Try adding the following line to the beginning of the job:
    mount -a
    You may need to add u and/or w to the command after the a without any additional spaces for the mount to work properly.
    (13951)

  • Help Please : Cron Job to automate load process

    Hi
    I am trying to automate data load process. I am loading data into a number of tables from flat files.
    Currently I have a UNIX (SunOS) file with a bunch of SQLLDR commands and I changed permission on this file to executable. Every morning I execute this file to load data.
    Now I want to automate this process by writing a cron job and scheduling it. I am running into a number of problems. I exported ORACLE_SID, ORACLE_HOME and PATH still cron is unable to find SQLLDR.
    Whatelse am I missing. Here is my command file and cron file.
    Please help!?!?!?
    ORAENV VARiables
    export ORACLE_HOME=/export/opt/oracle/product/8.1.6
    export ORACLE_SID=fid1
    export PATH=$PATH:$ORACLE_HOME/bin
    .profile
    . $HOME/oraenv
    daily_full.sql file
    export ORACLE_SID ORACLE_HOME PATH
    sqlldr userid=user/pwd control=acct.ctl log=acct.log
    sqlldr .......
    Cron Job
    16 11 * * 1-5 /apps/fire/data/loadscripts/daily_full.sql >> /apps/fire/data/loadscripts/fulllog.log 2>&1
    Output fulllog.log file
    /apps/fire/data/loadscripts/daily_full.sql: sqlldr: not found
    /apps/fire/data/loadscripts/daily_full.sql: sqlldr: not found
    Thanks
    Shanthi

    Hi Ramayanapu,
    first; you have written a shell-script not an sql-script. Please rename your file from daily_full.sql to daily_full.sh
    I suggest that you use the cronjob from a user who has the enviroment with the variables ORACLE_SID and ORACLE_HOME.
    In this case cron will operate from the $HOME variable of this user.
    Perhaps your export will destroy the .kshrc setting. The statement has no effect in your script, please remove it.
    Rename your sqlldr-Statement as follows;
    $ORACLE_HOME/bin/sqlldr userid=user/pwd control=<path>acct.ctl log=acct.log
    <path> will placed with the path of your controlfile.
    Your user/pwd will correspond with a ORACLE user who has the right to insert in the destination table.
    Your logfile will be place in the %HOME directory.
    Hope that i could help to solve your problems
    with kind regards
    Hans-Peter

  • Cron job to start machine.

    Is there a way to get the machine to start, open iTunes and start playing a song at a specified time using a cron job?
    MacBook Pro 15.4" - Intel Core Duo 2.0   Mac OS X (10.4.6)   2GB RAM

    I have my computer do exactly what you want yours to do, except I don't use a cron job. In case you don't actually need to use cron, I'll tell how I get it to happen.
    As mentioned by Federico_82, I use the Energy Saver preferences in System Preferences. There is an "Schedule..." button in the lower right corner that will allow you set the startup and/or shutdown times for the computer. It's not very detailed, but it suits my purposes for waking up Monday through Friday.
    I also have the computer automatically log me in using the Login Options in Accounts preferences in System Preferences.
    Finally, I've set alarms in iCal and chose "Open file" in the alarm section of the Info drawer. You can select a song file (or anything really) to be opened and the song will be played with iTunes since songs should automatically open with iTunes.
    I've also set the final option in the alarm section to perform this 5 minutes before the time I set for the event, with the event time being the same time as the computer startup. This is okay because it will perform an alarm that was suppose to happen even if it couldn't do it earlier, for example because the computer was off. So you don't have to worry about timing it perfectly. Just set the alarm time to the same as the startup time for the computer or earlier if you want it to happen immediately upon startup, then the alarm will go off immediately after computer turns on and logs you in.
    Also keep in mind you can set the event to repeat at various intervals in iCal, such as Monday through Friday or various discontinuous days of the week every week, and so on. Very customizable.
    Personally, I use an Automator app to start playing a playlist in iTunes, and to set the iTunes volume to an appropriate level to wake up with just in case I've change the volume the last time I used iTunes. In this way, I can simply change the song in the playlist in iTunes without having change the alarm event in iCal. This helps because then I can copy/paste the alarm anywhere I want and don't have to worry about finding another song file if I want to change the song. Instead, I simply find the song I want in iTunes and put it in the playlist, along with any other songs I want have played.
    If you do it with an Automator workflow, simply save the workflow as an iCal Alarm with "Save As Plug-in...". It'll automatically save in your ~/Library/Workflows/Applications/iCal folder, without you having to figure that out. Oh, and it doesn't hurt to test the workflow to make sure it plays your playlist (or whatever you have it do) before saving it as an iCal Alarm. Though, you can re-edit later if you want.
    Once you've saved your workflow as an iCal Alarm, it'll show up in list of files to open in the alarm section for the event. So, after you've chosen "Open file" in that section, the default for the file will be "iCal", but you'll also be able to choose any iCal alarms you've saved in Automator or any other file (such as a document or a song).
    Just as a bit of trivia, a plug-in you save in Automator is actually the same thing as saving your workflow as an application. The only difference is that the app is saved to a specific location so the Finder, or iCal, or Image Capture, etc., can find it. So, you don't have to know where to save it, Automator does that for you, but I told you where it is anyways (though you could use Spotlight) so you can get to it to edit it again if you want. Just drag and drop the app onto Automator or open it from within Automator to edit it again.
    I hope that helps. Though it might sound kind of complicated at first, I think this way is much easier than dealing with a crontab and trying to synchronize it with startup and so on. You'll also find this way very customizable with the various options for iCal alarms and the many possibilities with Automator (if you choose to use a workflow instead of simply a song file).

  • Shell Script gives error when run through cron job.

    Hi,
    The following shell script runs without any problem when executed manulally.
    USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
    if [ ${USED} -gt 90 ]
    then
    find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
    find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
    fi
    But the same gives below error when called from a cron job:
    /backup/arch_test.sh: syntax error at line 1: `USED=$' unexpected
    We are running following version:
    bash-3.00$ uname -a
    SunOS uaeaubdbdr01.aub.af 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise
    Kindly assist.
    Thanks
    Edited by: user13362786 on Apr 20, 2011 4:36 AM

    Hi,
    When I used #!/usr/bin/sh now even the manul execution of the script fails with the same err:
    bash-3.00$ ./arch_test.sh
    ./arch_test.sh: syntax error at line 2: `USED=$' unexpected
    And when I used #!/usr/bin/ksh the manual execution runs fine but again when the script is run from cronjob it now give dirrect err:
    /backup/arch_test.sh[2]: df: not found
    /backup/arch_test.sh[2]: tail: not found
    /backup/arch_test.sh[2]: cut: not found
    /backup/arch_test.sh[2]: awk: not found
    /backup/arch_test.sh[3]: test: argument expected

  • Reg Cron Jobs

    hi,
    I need to run a cron job every alternate wednesdays...in a year
    Any suggestions????
    Thnx,
    Enz

    Method 1: Run a cron job every wednesday. Run your job if `date +%U` is even.
    problems: Some years will have 53 wednesdays, so eventually you'll run your job on consecutive weeks.
    Method 2: Run a cron job every wednesday. Set a file as a sentinel. If clear, set it and run your job. If set, clear it and dont' run the job.
    problems: If the cron job fails to run, your "alternate week" might get out of sync. Someone might screw up the sentinel file.
    Pick one based on your needs
    Darren

  • Cron job emCCR after installed OBI11.1.1.5.0

    OBIEE 11.1.1.5.0 on Rdhat 5.2. After installation saw a cron job created0,15,30,45 * * * * ORACLE_CONFIG_HOME=/u01/app/obi11115/instances/obi11_dev /u01/app/obi11115/Oracle_BI1/ccr/bin/emCCR -cron -silent start emCCR appears to be Configuration Manager. But do I have a Configuration Manager running for a default installation of OBI 11.1.1.5.0 Enterprise? If not does it has impact on my OBIE11
    Thanks

    A restart solved the issue.

  • Cron job "best way"

    Hello,
    Which is the best way to create a cron job for a sql script?
    Thank you!

    1) each time you change your cron settings, add a job, delete, etc. save the latest state into a text file, dated. this way you have a log of changes. Example:
    crontab -l > cron.mmddyy
    2) make sure you have standard include files that contain all the environment (ORACLE_HOME, ORACLE_SID) and user names+passwords. These should be kept separate from the scripts, so that:
    - you can include them in all scripts
    - apply strict security access
    the script can apply the env files to get the info. same as you apply the "oraenv" command in your shell prompt.
    3) make sure each cron job leaves a detailed log, including errors. Examine the logs on a frequent basis. The shell script should try to catch errods and email them to the admin whenever possible. Example:
    0 0 * * * /folder/script.sh /folder2/script.env > /folder3/script.log 2>&1

Maybe you are looking for