For what its worth, using a script to create a cron job as the root user may lead to some odd, hard to find and possibly dangerous bugs. You may want to rethink your approach.
I think the approach is OK. Maybe thread-o/p is trying to set up a mechanism to deploy a cron job for a lot of systems: think, for instance, of a database backup script to be run as the DBA user. If i had to create such a system i would write exactly such a (postinstall-) script and put it into a package, along with the script to be called from cron itself.
For cron to become aware of the changed crontab you just need to send it a HUP signal:
but even if this works i'd still prefer rbatte1's solution because this will work even when the involved path for the crontabs and/or the location of the PID-file changes with different cron-implementations.
Btw.: i suggest to add redirections to /dev/null (or designated log files) otherwise cron would start to mail stray output to the user. Another thing: check if the user is allowed to have a crontab. In most implementations there is a file /etc/cron.allow and another file /etc/cron.deny.
Although there are many threads on this forum regarding cron, none have specifically answered my question. So hopefully someone can shed some light on what I'm doing wrong..
I have a perl script that I want to run in a cron job. Since I've read that cron doesn't have any environments set, I... (3 Replies)
Hi, new to this forum and not sure if this is the right place to post. I'm new to cron jobs and scripts, and I need some help with a script to be used with a cron job. I already have a bot set up at a certain website address and need a script that the cron job will load every day that tells it to... (1 Reply)
Greetings,
I am creating a ksh script to automate the installation of a utility on many servers.
As part of this install, I want to check for a job in root's crontab.
If the job exists, I need to comment it out.
I know I will need to copy off the crontab then read it back in, but I am... (4 Replies)
Hey Guys,
i was trying out a shell script which has to remove a file for every 90 mins. this is the code i came up with .
$ crontab -e file1
file1 contains
30 1 * * * * rm -r /folder1/folder2/somefile.txt
Now i need the cron to run for every 90 mins. the problem with this is... (8 Replies)
Hi
A Ksh script is deployed in a server and executed through cronjob.
If one of the line in the middle of the script fails . Are the remaining lines executed ? (3 Replies)
Hi,
I am trying to submit a job to a queue on a cluster. When I run the job ( python script) from the command line it runs without putting python at the start. The script imports everything from another congifuration file (.config) but when I submit to the queue it tells me there is no module... (0 Replies)
Hello,
How do I schedule a cron job for a phython script to run every hour?
Also, in case in future I decide to edit/cancel the job how should i do it?
Does it matter where my phython script is located? Also, I have am using mailx utility in my script to send me an email and dont want... (7 Replies)
Hi Team,
When i am running the below query manually it is giving me the right output
i.e.
export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH
ADMIN=abc@abc.com
CPU_HIGH=`sar|awk '{print $9}'|sort -n|head -5|sed -n 5p`
CPU_MAX=`echo "scale=3; 100-$CPU_HIGH" | bc`
CPU_LOW=`sar|awk '{print... (13 Replies)
I've created a script to copy backup files from an HP-UX 11iv3 system to an NFS share on another machine. I want to schedule the script to run via cron. The script is simply three lines of cp /backups/Backup /shared/Backup. I've saved the script as a .sh file and call it with KSH. Do I need to... (3 Replies)
Discussion started by: jduehmig
3 Replies
LEARN ABOUT SUSE
crontab
CRONTAB(1) General Commands Manual CRONTAB(1)NAME
crontab - maintain crontab files for individual users (ISC Cron V4.1)
SYNOPSIS
crontab [-u user] file
crontab [-u user] [-l | -r | -e]
DESCRIPTION
Crontab is the program used to install, deinstall or list the tables used to drive the cron(8) daemon in ISC Cron. Each user can have
their own crontab, and though these are files in /var, they are not intended to be edited directly.
If the cron.allow file exists, then you must be listed therein in order to be allowed to use this command. If the cron.allow file does not
exist but the cron.deny file does exist, then you must not be listed in the cron.deny file in order to use this command. If neither of
these files exists, only the super user will be allowed to use this command.
If the -u option is given, it specifies the name of the user whose crontab is to be tweaked. 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.
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.
SEE ALSO crontab(5), cron(8)FILES
/etc/cron.allow
/etc/cron.deny
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.
AUTHOR
Paul Vixie <vixie@isc.org>
4th Berkeley Distribution 29 December 1993 CRONTAB(1)