Visit Our UNIX and Linux User Community

Crontab commands [crontab -e/r] issues

Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Crontab commands [crontab -e/r] issues
# 1  
Old 04-12-2020
Crontab commands [crontab -e/r] issues

Hello All,

My project needs, people to work with the crontab frequently . As the letters e/r are adjacent to each other , many times
crontab -r

command was issued unintentionally instead of
crontab -e

and we end up deleting the crontab .

Is there a way, that I can make it interactive so that upon executing any

command it will ask for confirmation.

Many Thanks.
# 2  
Old 04-12-2020
You could write a script that asks and then executes /bin/crontab. Put this in the PATH before /bin (eg /usr/local/bin):

Script could be something like this as an example. You may not want to prompt if ACTION is empty, I'll leave that as a exercise for you:

function yorn
   while [ "${yn}:" = ":" ]
       printf "%s (y/n)? " "$1"
       read yn

       case $yn in
           [yY]|[Yy][Ee][Ss]) true;;
           [nN]|[nN][oO]) false;;
           *) yn="";;

while getopts reu:l arg
 case $arg in

if yorn "Are you sure you want to $ACTION"
     # They said yes so execute: /bin/crontab $@
    /bin/crontab $@
     echo "Abort"

These 2 Users Gave Thanks to Chubler_XL For This Post:
# 3  
Old 04-13-2020
A bit more portable (ash, dash) is

And test takes -z
while [ -z "$yn" ]

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Crontab <foldername> - removed the whole crontab

Hello, Hope you are doing great though the situation is not so good #Corona. By mistake I ran the below command and my crontab is gone now . Could anyone please let me know what this command actually does and if possible how to recover the crontab entry. ccs is one of my... (6 Replies)
Discussion started by: Showdown
6 Replies

2. Shell Programming and Scripting

RMAN commands inside crontab shell script

Hello I'm trying to write simple script to delete archive logs for RMAN, unfortunately it's not working, I tried two way to do that: #!/bin/ksh echo "Start ....." rman target=/ << EOF RUN { delete force noprompt archivelog until time 'sysdate-10'; } EXIT; EOF echo "END ..." echo... (6 Replies)
Discussion started by: samer.odeh
6 Replies

3. Solaris

crontab job issues with export command

Hi all, I have sevaral jbos with bunch of export commands like export VARIABLE=value. They work perfectly when I run manually but when I try to run from crontab it stops right at this export command. But when I replace these export with these, crontab job works fine. VARIABLE = value;... (5 Replies)
Discussion started by: MKNENI
5 Replies

4. UNIX for Dummies Questions & Answers

HELP with crontab

I am trying to create a crontab but I keep getting a "bad minute" error. Here is what I am entering: */5****/usr/bin/php/ {path to script} After I exit the editor and save I get the following message: crontab: installing new crontab "/temp/crontab." :-2: bad minute errors in... (2 Replies)
Discussion started by: fcocnews
2 Replies

5. Solaris

cron / crontab issues - solaris 10

I am having some issues with my cronjobs not running in solaris 10. Cron is running: ~> ps -ef | grep cron root 202 1 0 Jul 18 ? 0:01 /usr/sbin/cron bender 1646 1562 0 01:57:49 syscon 0:00 grep cron crontab -l lists the cronjob and I *think* its in the... (8 Replies)
Discussion started by: ippy98
8 Replies

6. AIX

crontab isn't excuting some commands

Greetings everybody, I have an IBM P520 AIX 5.3 server machine and trying to use crontab to periodically excute a script that contains a command belongs to my software (Fast/Tools SCADA software) I added the following line after using crontab -e 01 * * * * /mypath/myscript I have two... (3 Replies)
Discussion started by: ayman metwally
3 Replies

7. Shell Programming and Scripting

Crontab help

Hi Guys, This is a line in my crontab. 07 15 24 11 6 /usr/local/dsadm/dsprod/src/ 2>&1 I understood as the script is to run on 24 of nov at 3 07 pm. But the script is running on every sat at 03 07 pm. could anyone help me out with this and clarify my doubt?? ... (4 Replies)
Discussion started by: mac4rfree
4 Replies

8. UNIX for Advanced & Expert Users

Crontab help

hi, I run a .sh file using crontab. I need to know the path of the file . Previously when I run the file alone , i used "pwd" but now when using crontab it gives the temp directory of the file. Is there any way I can find the absolute path of the file when i execute it ? Regards, Ranga (7 Replies)
Discussion started by: r_W213
7 Replies

9. Shell Programming and Scripting

Issues using ssh from crontab to run remote script from

I have a solaris9 x86 server using ssh as follows: SSH Version Sun_SSH_1.0, protocol versions 1.5/2.0. The remote server solaris9 sparc has exactly the same version ssh installed. I am running a script on my server which includes the following command to run a script on the remote server:... (4 Replies)
Discussion started by: frustrated1
4 Replies

10. UNIX for Dummies Questions & Answers

differnce between working of at and crontab commands

h I would like to know the differnce (both working and how) between at command and crontab.. Thanks in advance Satish D (2 Replies)
Discussion started by: doddas
2 Replies

Featured Tech Videos