Sponsored Content
Top Forums UNIX for Dummies Questions & Answers crontab every 2 minutes, 24 hours and once a week Post 302117945 by Shell_Life on Thursday 17th of May 2007 09:57:32 AM
Old 05-17-2007
Ok, assuming this is not a homework, here is the format of "crontab":
Code:
minute  hour  day_of_month  month  day_of_week  <command>

Specifying "*" means every occurence.
You can separate multiple values by comma, example:
if you enter: 1,3,5 in the "hour" parameter, it means you want your
job to run at 1:00, 3:00 and 5:00 o'clock.
You can also enter ranges using "-" (dash) in between numbers:
7-12 means all acceptable values between 7 and 12, including both.

Last edited by Shell_Life; 05-17-2007 at 11:04 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

2. Shell Programming and Scripting

Difference in day-hours-minutes-seconds format

Hi experts, I am reading two log files and passing dates as output to a txt file. Code is given below: echo "Start Time:" >> Report.txt cat start.log | while read LINE1 do echo $DATE1 >> Report.txt done echo "End Time:" >> Report.txt cat end.log | while read LINE2 ... (7 Replies)
Discussion started by: Sreejith_VK
7 Replies

3. Shell Programming and Scripting

Reading Hours and Minutes from file and comparing with current

Hi, Time till when the application should run is indicated in a file. First line is hour and second line is minute. file: 10 55 Means my application should run till 10:55. Now in a shell script, i am trying to make that logic but with no luck. min=`tail -n 1 /file_with_time`... (1 Reply)
Discussion started by: SGD
1 Replies

4. Shell Programming and Scripting

Cron job for every five minutes and between hours

Hi I need to run a script every five minutes and it should run between 07-15 hours all days. How i can achieve this... i tried like this */5 07-15 * * * /scripts/CreateFtpData.sh It throws an error... (1 Reply)
Discussion started by: aemunathan
1 Replies

5. Shell Programming and Scripting

Process Time in hours or minutes only

Hi i want to print the time of a process in hours only..(or) in minutes only.Is there anyway to print the process such like that when i give the commnand like following #ps -eo pid,time PID TIME 412 01:49:32 481 00:03 it shows in HH:MM:SS format: Could anyone... (1 Reply)
Discussion started by: srikanthg
1 Replies

6. Shell Programming and Scripting

How to split numeric value into hours:minutes:seconds

I have a problem. I am working on a Call Detail Report system. Come to find out the phone switch does not report in seconds. It is a 5 digit field that reports h:mm:ss The problem is I have 1-5 digit numbers Ie 1 = 1 second and should be reported as 0:00:01 22 should be 0:00:22 321 should be... (5 Replies)
Discussion started by: truecall
5 Replies

7. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

8. What is on Your Mind?

How many hours do you spend at unix.com a week ?

This includes the time you spend reading threads, answering them and all the other activities at unix.com on an average for a week. This poll is about your time with unix.com :b: Poll and if possible just drop a short note about which part of the day you spend the most !!! I hope this is... (32 Replies)
Discussion started by: matrixmadhan
32 Replies

9. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

10. UNIX for Beginners Questions & Answers

Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi I want to replace time stamp in the following line PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read assuming the new time stamp is 09:45 ; the line is getting replaced as below :45 read I'm trying to use the perl one liner in bash script perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies
smcron(1M)						  System Administration Commands						smcron(1M)

NAME
smcron - manage jobs in the crontab database SYNOPSIS
/usr/sadm/bin/smcron subcommand [ auth_args] -- [subcommand_args] DESCRIPTION
The smcron command manages jobs in the crontab(1) database. subcommands smcron subcommands are: add Adds a job to the crontab(1) database. To add a job, the administrator must have the solaris.jobs.user authorization. To add a job to another user's crontab file, the administrator must have the solaris.jobs.admin authorization. delete Deletes a job from the crontab(1) database. To delete a job, the administrator must have the solaris.jobs.user authoriza- tion. To delete a job from another user's crontab file, the administrator must have the solaris.jobs.admin authorization. list Lists one or more jobs in the crontab(1) database. To list all jobs, the administrator must have the solaris.jobs.user authorization. To list a job in another user's crontab file, the administrator must have the solaris.jobs.admin authoriza- tion. No authorization is needed to list a user's own jobs. modify Modifies a job in the crontab(1) database. To modify a job, the administrator must have the solaris.jobs.user authoriza- tion. To modify a job in another user's crontab file, the administrator must have the solaris.jobs.admin authorization. OPTIONS
The smcron authentication arguments, auth_args, are derived from the smc(1M) arg set and are the same regardless of which subcommand you use. The smcron command requires the Solaris Management Console to be initialized for the command to succeed (see smc(1M)). After reboot- ing the Solaris Management Console server, the first Solaris Management Console connection might time out, so you might need to retry the command. The subcommand-specific options, subcommand_args, must come after the auth_args and must be separated from them by the -- option. auth_args The valid auth_args are -D, -H, -l, -p, -r, and -u; they are all optional. If no auth_args are specified, certain defaults will be assumed and the user may be prompted for additional information, such as a password for authentication purposes. These letter options can also be specified by their equivalent option words preceded by a double dash. For example, you can use either -D or --domain with the domain argu- ment. -D | --domain domain Specifies the default domain that you want to manage. smcron accepts only file for this option. file is also the default value. The file default domain means that changes are local to the server. Toolboxes can change the domain on a tool-by-tool basis; this option specifies the domain for all other tools. -H | --hostname host_name:port Specifies the host_name and port to which you want to connect. If you do not specify a port, the system connects to the default port, 898. If you do not specify host_name:port, the Solaris Management Console connects to the local host on port 898. You may still have to choose a toolbox to load into the console. To override this behavior, use the smc(1M) -B option, or set your console preferences to load a "home toolbox" by default. -l | --rolepassword role_password Specifies the password for the role_name. If you specify a role_name but do not specify a role_password, the system prompts you to sup- ply a role_password. Passwords specified on the command line can be seen by any user on the system, hence this option is considered insecure. -p | --password password Specifies the password for the user_name. If you do not specify a password, the system prompts you for one. Passwords specified on the command line can be seen by any user on the system, hence this option is considered insecure. -r | --rolename role_name Specifies a role name for authentication. If you do not specify this option, no role is assumed. -u | --username user_name Specifies the user name for authentication. If you do not specify this option, the user identity running the console process is assumed. -- This option is required and must always follow the preceding options. If you do not enter the preceding options, you must still enter the -- option. subcommand_args For the time-related subcommands described below, -m, -M, -t, and -w, you can enter multiple arguments, separated only by commas. smcron will construct crontab entries appropriate for your arguments. See EXAMPLES. Note: Descriptions and other arg options that contain white spaces must be enclosed in double quotes. o For subcommand add: -c command Specifies the command that you want to run. -h (Optional) Displays the command's usage statement. -m day_of_month (Optional) Specifies the day of the month you want to run the job. Valid values are 1-31. If you specify both -t and -m options, the job executes one day per month at the time specified by -t. -M month (Optional) Specifies the month that you want to run the job. Valid values are 1-12. If you specify both -t and -M options, the job executes during the specified month at the time specified by -t. -n name Specifies the unique name of the job. -o owner (Optional) Specifies the user name that is the owner of the job. If you do not specify this option, the user name specified by the -U option is assumed. -t time_of_day Specifies the time (in hh:mm) that you want to execute the command. If no other time-related options are specified (-m, -M, or -w), the job executes every day at the time specified by -t. If you specify both -t and -w options, the job executes one day per week at the time specified by -t. If you specify both -t and -m options, the job executes one day per month at the time specified by -t. If you specify both -t and -M options, the job executes each day during the specified month at the time specified by -t. -w day_of_week (Optional) Specifies the day of the week you want to execute the command. Valid values are as follows: o 0=Sunday o 1=Monday o 2=Tuesday o 3=Wednesday o 4=Thursday o 5=Friday o 6=Saturday If you specify both -t and -w options, the job executes one day per week at the time specified by -t. o For subcommand delete: -h (Optional) Displays the command's usage statement. -n name Specifies the unique name of the job. -o owner (Optional) Specifies the user name that is the owner of the job. If you do not specify this option, the user name specified by the -U option is assumed. o For subcommand list: -f n|s|v (Optional) Specifies the format of the output. See EXAMPLES for examples of each output type. o n -- Displays the data in native format, as it appears in the crontab(1) database. o s -- Default format. Displays the data in summary format. o v -- Displays the data in verbose format. -h (Optional) Displays the command's usage statement. -o owner (Optional) Lists all jobs for the specified owner (user name). If you do not specify this option, all jobs in the crontab(1) data- base are listed. o For subcommand modify: -c command (Optional) Specifies the command that you want to run. -h (Optional) Displays the command's usage statement. -m day_of_month (Optional) Specifies the day of the month you want to run the job. Valid values are 1-31. If you specify both -t and -m options, the job executes one day per month at the time specified by -t. -M month (Optional) Specifies the month that you want to run the job. Valid values are 1-12. If you specify both -t and -M options, the job executes during the specified month at the time specified by -t. -n name Specifies the current unique name of the job. -N new_name (Optional) Specifies the new unique name of the job. -o owner (Optional) Specifies the user name that is the owner of the job. If you do not specify this option, the user name specified by the -U option is assumed. -O new_owner (Optional) Specifies the new owner of the job. -t time_of_day (Optional) Specifies the time (in hh:mm) that you want to execute the command. If no other time-related options are specified (-m, -M, or -w), then the job executes every day at the time specified by -t. If you specify both -t and -w options, the job executes one day per week at the time specified by -t. If you specify both -t and -m options, the job executes one day per month at the time specified by -t. If you specify both -t and -M, then the job executes each day during the specified month at the time speci- fied by -t. -w day_of_week (Optional) Specifies the day of the week you want to execute the command. Valid values are as follows: o 0=Sunday o 1=Monday o 2=Tuesday o 3=Wednesday o 4=Thursday o 5=Friday o 6=Saturday If you specify both -t and -w options, the job executes one day per week at the time specified by -t. EXAMPLES
Example 1: Adding a Job The following adds a new job, owned by root, that removes the old log files from /tmp daily at 1:30 AM. ./smcron add -H myhost -u root -p mypassword -- -n "Remove old logs" -t 1:30 -c "rm /tmp/*.log" -o root Example 2: Deleting a Job The following deletes the job Remove old logs owned by root: ./smcron delete -H myhost -u root -p mypassword -- -n "Remove old logs" -o root Example 3: Listing Jobs in Native Format The following lists all jobs in native, or crontab(1), format: ./smcron list -H myhost -u root -p mypassword -- -f n MINUTE HOUR DATE MONTH DAY COMMAND 10 3 * * * /usr/sbin/logadm 15 3 * * 0 /usr/lib/fs/nfs/nfsfind 1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1 30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean Example 4: Listing Jobs in Standard Format The following lists all jobs owned by lp in standard format: ./smcron list -H myhost -u root -p mypassword -- -f s -o lp NAME::OWNER::SCHEDULE::COMMAND NoName_1765663371::lp::Weekly on Sundays at 3:13 AM::cd /var/lp/logs; if [ -f requests ]; then if [ -f requests.1 ]; then /bin/mv requests.1 requests.2; fi; /usr/bin/cp requests requests.1; > requests; fi NoName_512822673::lp::Weekly on Sundays at 4:15 AM::cd /var/lp/logs; if [ -f lpsched ]; then if [ -f lpsched.1 ]; then /bin/mv lpsched.1 lpsched.2; fi; /usr/bin/cp lpsched lpsched.1; >lpsched; fi Example 5: Listing jobs in verbose format The following lists all jobs in verbose format: ./smcron list -H myhost -u root -p mypassword -- -f v NAME::OWNER::SCHEDULE::NEXT_RUN::STATUS::COMMAND NoName_1075488942::root::Advanced::::Finished on Feb 10 3:10 with code 1 ::/etc/cron.d/logchecker databackup::root::Weekly on Sundays at 3:10 AM::3/19/00 3:10 AM ::Finished on Sep 19 3:10::/usr/lib/newsyslog runlog::root::Daily at 2:01 AM::3/14/00 2:01 AM::Finished on Feb 11 2:01 AM::/usr/sbin/rtc Example 6: Changing a Job The following modifies the job Remove old logs owned by root to execute daily at 2:00 AM: ./smcron modify -H myhost -u root -p mypassword -- -n "Remove old logs" -o root -t 2:00 Example 7: Specifying Multiple Time Arguments smcron allows you to specify a range of times for all of its time-related subcommands, -m, -M, -t, and -w. For example, the following com- mand: # smcron add -u root -p xxxx -- -n cronjob1 -w 1-4,5 -t 12:00,13:15,14:30 -c ls ...creates the following entry in crontab: 0,15,30 12,13,14 * * 1,2,3,4,6 ls #cronjob1 This job would run on Monday through Thursday and Saturday at the following times: 12:00 12:15 12:30 13:00 13:15 13:30 14:00 14:15 14:30 ENVIRONMENT VARIABLES
See environ(5) for a description of the JAVA_HOME environment variable, which affects the execution of the smcron command. If this envi- ronment variable is not specified, the /usr/java location is used. See smc(1M). EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 Invalid command syntax. A usage message displays. 2 An error occurred while executing the command. An error message displays. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWmga | +-----------------------------+-----------------------------+ SEE ALSO
crontab(1), cron(1M), smc(1M), attributes(5), environ(5) NOTES
The timezone of the cron daemon sets the system-wide timezone for cron entries. This, in turn, is by set by default system-wide using /etc/default/init. If some form of daylight savings or summer/winter time is in effect, then jobs scheduled during the switchover period could be executed once, twice, or not at all. SunOS 5.10 24 Mar 2003 smcron(1M)
All times are GMT -4. The time now is 04:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy