Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Crontab commands [crontab -e/r] issues Post 303045767 by Chubler_XL on Sunday 12th of April 2020 01:31:56 PM
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:

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

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

while getopts reu:l arg
do
 case $arg in
   r) ACTION=${ACTION}REMOVE;;
   e) ACTION=${ACTION}EDIT;;
 esac
done

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

These 2 Users Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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/run_ipoval.sh 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CRONTAB(1)                                                    General Commands Manual                                                   CRONTAB(1)

NAME
crontab - maintain crontab files for individual users (Vixie Cron) SYNOPSIS
crontab [ -u user ] file crontab [ -u user ] [ -i ] { -e | -l | -r } DESCRIPTION
crontab is the program used to install, deinstall or list the tables used to drive the cron(8) daemon in Vixie Cron. Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. If the /etc/cron.allow file exists, then you must be listed (one user per line) therein in order to be allowed to use this command. If the /etc/cron.allow file does not exist but the /etc/cron.deny file does exist, then you must not be listed in the /etc/cron.deny file in order to use this command. If neither of these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users will be able to use this command. If both files exist then /etc/cron.allow takes precedence. Which means that /etc/cron.deny is not considered and your user must be listed in /etc/cron.allow in order to be able to use the crontab. Regardless of the existance of any of these files, the root administrative user is always allowed to setup a crontab. For standard Debian systems, all users may use this command. If the -u option is given, it specifies the name of the user whose crontab is to be used (when listing) or modified (when editing). If this option is not given, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su(8) can confuse crontab and that if you are running inside of su(8) you should always use the -u option for safety's sake. The first form of this command is used to install a new crontab from some named file or standard input if the pseudo-filename ``-'' is given. The -l option causes the current crontab to be displayed on standard output. See the note under DEBIAN SPECIFIC below. The -r option causes the current crontab to be removed. The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. If neither of the environment variables is defined, then the default editor /usr/bin/editor is used. The -i option modifies the -r option to prompt the user for a 'y/Y' response before actually removing the crontab. DEBIAN SPECIFIC
The "out-of-the-box" behaviour for crontab -l is to display the three line "DO NOT EDIT THIS FILE" header that is placed at the beginning of the crontab when it is installed. The problem is that it makes the sequence crontab -l | crontab - non-idempotent -- you keep adding copies of the header. This causes pain to scripts that use sed to edit a crontab. Therefore, the default behaviour of the -l option has been changed to not output such header. You may obtain the original behaviour by setting the environment variable CRONTAB_NOHEADER to 'N', which will cause the crontab -l command to emit the extraneous header. SEE ALSO
crontab(5), cron(8) FILES
/etc/cron.allow /etc/cron.deny /var/spool/cron/crontabs There is one file for each user's crontab under the /var/spool/cron/crontabs directory. Users are not allowed to edit the files under that directory directly to ensure that only users allowed by the system to run periodic tasks can add them, and only syntactically correct crontabs will be written there. This is enforced by having the directory writable only by the crontab group and configuring crontab com- mand with the setgid bid set for that specific group. STANDARDS
The crontab command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command syntax differs from previous versions of Vixie Cron, as well as from the classic SVR3 syntax. DIAGNOSTICS
A fairly informative usage message appears if you run it with a bad command line. cron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it. AUTHOR
Paul Vixie <paul@vix.com> is the author of cron and original creator of this manual page. This page has also been modified for Debian by Steve Greenland, Javier Fernandez-Sanguino and Christian Kastner. 4th Berkeley Distribution 19 April 2010 CRONTAB(1)
All times are GMT -4. The time now is 04:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy