Print this page
13066 Want crontab -u
Change-ID: I3dc2251dbbcc721aeff25a9dde21a24271c927bc
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/crontab.1.man.txt
+++ new/usr/src/man/man1/crontab.1.man.txt
1 1 CRONTAB(1) User Commands CRONTAB(1)
2 2
3 3
4 4
5 5 NAME
6 6 crontab - user crontab file
7 7
8 8 SYNOPSIS
9 - /usr/bin/crontab [filename]
9 + /usr/bin/crontab [-u username] [filename]
10 10
11 11
12 - /usr/bin/crontab -e [username]
12 + /usr/bin/crontab { -e | -l | -r } [username]
13 13
14 14
15 - /usr/bin/crontab -l [username]
15 + /usr/bin/crontab -u username { -e | -l | -r }
16 16
17 17
18 - /usr/bin/crontab -r [username]
19 -
20 -
21 18 /usr/xpg4/bin/crontab [filename]
22 19
23 20
24 - /usr/xpg4/bin/crontab -e [username]
21 + /usr/xpg4/bin/crontab { -e | -l | -r } [username]
25 22
26 23
27 - /usr/xpg4/bin/crontab -l [username]
24 + /usr/xpg4/bin/crontab -u username { -e | -l | -r }
28 25
29 26
30 - /usr/xpg4/bin/crontab -r [username]
31 -
32 -
33 27 /usr/xpg6/bin/crontab [filename]
34 28
35 29
36 - /usr/xpg6/bin/crontab -e [username]
30 + /usr/xpg6/bin/crontab { -e | -l | -r } [username]
37 31
38 32
39 - /usr/xpg6/bin/crontab -l [username]
33 + /usr/xpg6/bin/crontab -u username { -e | -l | -r }
40 34
41 35
42 - /usr/xpg6/bin/crontab -r [username]
43 -
44 -
45 36 DESCRIPTION
46 37 The crontab utility manages a user's access with cron (see cron(1M)) by
47 38 copying, creating, listing, and removing crontab files. If invoked
48 39 without options, crontab copies the specified file, or the standard
49 40 input if no file is specified, into a directory that holds all users'
50 41 crontabs.
51 42
52 43
53 44 If crontab is invoked with filename, this overwrites an existing
54 - crontab entry for the user that invokes it.
45 + crontab entry for the user that invokes it, or for the user specified
46 + with the -u option.
55 47
56 48 crontab Access Control
57 49 Users: Access to crontab is allowed:
58 50
59 51 o if the user's name appears in /etc/cron.d/cron.allow.
60 52
61 53 o if /etc/cron.d/cron.allow does not exist and the user's name
62 54 is not in /etc/cron.d/cron.deny.
63 55
64 56
65 57 Users: Access to crontab is denied:
66 58
67 59 o if /etc/cron.d/cron.allow exists and the user's name is not
68 60 in it.
69 61
70 62 o if /etc/cron.d/cron.allow does not exist and user's name is
71 63 in /etc/cron.d/cron.deny.
72 64
73 65 o if neither file exists, only a user with the
74 66 solaris.jobs.user authorization is allowed to submit a job.
75 67
76 68 o if Auditing is enabled, the user's shell is not audited and
77 69 the user is not the crontab owner. This can occur if the
78 70 user logs in by way of a program, such as some versions of
79 71 SSH, which does not set audit parameters.
80 72
81 73
82 74 The rules for allow and deny apply to root only if the allow/deny files
83 75 exist.
84 76
85 77
86 78 The allow/deny files consist of one user name per line.
87 79
88 80 crontab Entry Format
89 81 A crontab file consists of lines of six fields each. The fields are
90 82 separated by spaces or tabs. The first five are integer patterns that
91 83 specify the following:
92 84
93 85 minute (0-59),
94 86 hour (0-23),
95 87 day of the month (1-31),
96 88 month of the year (1-12),
97 89 day of the week (0-6 with 0=Sunday).
98 90
99 91
100 92
101 93
102 94 Each of these patterns can be either an asterisk (meaning all legal
103 95 values) or a list of elements separated by commas. An element is either
104 96 a number or two numbers separated by a hyphen (meaning an inclusive
105 97 range).
106 98
107 99 A range or asterisk can optionally be followed by a step value as
108 100 /<number>. For example, 2-59/3 can be used in the minutes field to
109 101 specify every three minutes starting at 2 past the hour, or */2 in the
110 102 hours field means every two hours.
111 103
112 104 Time specified here is interpreted in the currently active timezone. At
113 105 the top of the crontab file this is the timezone which is set system-
114 106 wide in /etc/default/init. A user can add a line such as:
115 107
116 108 TZ=timezone
117 109
118 110
119 111
120 112
121 113 ...and all subsequent entries will be interpreted using that timezone,
122 114 until a new TZ=timezone line is encountered. The specification of days
123 115 can be made by two fields (day of the month and day of the week). Both
124 116 are adhered to if specified as a list of elements. See EXAMPLES.
125 117
126 118
127 119 The sixth field of a line in a crontab file is a string that is
128 120 executed by the shell at the specified times. A percent character in
129 121 this field (unless escaped by \) is translated to a NEWLINE character.
130 122
131 123
132 124 Only the first line (up to a `%' or end of line) of the command field
133 125 is executed by the shell. Other lines are made available to the command
134 126 as standard input. Any blank line or line beginning with a `#' is a
135 127 comment and is ignored.
136 128
137 129
138 130 The shell is invoked from your $HOME directory. As with $TZ, both
139 131 $SHELL and $HOME can be set by having a line such as:
140 132
141 133 SHELL=/usr/bin/someshell
142 134
143 135
144 136
145 137
146 138 ...or:
147 139
148 140 HOME=somedirectory
149 141
150 142
151 143
152 144
153 145 ...which will take precedence for all the remaining entries in the
154 146 crontab or until there is another HOME or SHELL entry. It is invoked
155 147 with an arg0 of the basename of the $SHELL that is currently in effect.
156 148 A user who wants to have his .profile or equivalent file executed must
157 149 explicitly do so in the crontab file. cron supplies a default
158 150 environment for every shell, defining HOME, LOGNAME, SHELL, TZ, and
159 151 PATH. The default PATH for user cron jobs is /usr/bin; while root cron
160 152 jobs default to /usr/sbin:/usr/bin. The default PATH can be set in
161 153 /etc/default/cron (see cron(1M)). The TZ, HOME, and SHELL environment
162 154 variables are set to match those that are in effect in the crontab file
163 155 at the time.
164 156
165 157
166 158 If you do not redirect the standard output and standard error of your
167 159 commands, any generated output or errors are mailed to you.
168 160
169 161 crontab Environment Variables
170 162 The following variables are supported:
171 163
172 164 HOME
173 165
174 166 Allows the user to choose and alternative directory for cron to
175 167 change directory to prior to running the command. For example:
176 168
177 169 HOME=/var/tmp
178 170
179 171
180 172
181 173
182 174 SHELL
183 175
184 176 The name of the shell to use to run subsequent commands. For
185 177 example:
186 178
187 179 SHELL=/usr/bin/ksh
188 180
189 181
190 182
191 183
192 184 TZ
193 185
194 186 Allows the user to choose the timezone in which the cron entries
195 187 are run. This effects both the environment of the command that is
196 188 run and the timing of the entry. For example, to have your entries
197 189 run using the timezone for Iceland, use:
198 190
199 191 TZ=Iceland
200 192
201 193
202 194
203 195
204 196
205 197 Each of these variables affects all of the lines that follow it in the
206 198 crontab file, until it is reset by a subsequent line resetting that
207 199 variable. Hence, it is possible to have multiple timezones supported
208 200 within a single crontab file.
209 201
210 202
211 203 The lines that are not setting these environment variables are the
212 204 same as crontab entries that conform to the UNIX standard and are
213 205 described elsewhere in this man page.
214 206
215 207 Setting cron Jobs Across Timezones
216 208 The default timezone of the cron daemon sets the system-wide timezone
217 209 for cron entries. This, in turn, is by set by default system-wide using
218 210 /etc/default/init.
219 211
220 212
221 213 If some form of daylight savings or summer/winter time is in effect,
222 214 then jobs scheduled during the switchover period could be executed
223 215 once, twice, or not at all.
224 216
225 217 OPTIONS
226 218 The following options are supported:
227 219
228 220 -e
229 221 Edits a copy of the current user's crontab file, or creates an
230 222 empty file to edit if crontab does not exist. When editing is
231 223 complete, the file is installed as the user's crontab file.
232 224
233 225 The environment variable EDITOR determines which editor is
234 226 invoked with the -e option. All crontab jobs should be submitted
235 227 using crontab. Do not add jobs by just editing the crontab file,
236 228 because cron is not aware of changes made this way.
237 229
238 230 If all lines in the crontab file are deleted, the old crontab
239 231 file is restored. The correct way to delete all lines is to
240 232 remove the crontab file using the -r option.
241 233
242 234 If username is specified, the specified user's crontab file is
243 235 edited, rather than the current user's crontab file. This can
244 236 only be done by root or by a user with the solaris.jobs.admin
245 237 authorization.
246 238
247 239
248 240 -l
249 241 Lists the crontab file for the invoking user. Only root or a user
250 242 with the solaris.jobs.admin authorization can specify a username
251 243 following the -l option to list the crontab file of the specified
↓ open down ↓ |
187 lines elided |
↑ open up ↑ |
252 244 user.
253 245
254 246
255 247 -r
256 248 Removes a user's crontab from the crontab directory. Only root or
257 249 a user with the solaris.jobs.admin authorization can specify a
258 250 username following the -r option to remove the crontab file of
259 251 the specified user.
260 252
261 253
254 + -u username
255 + Specifies the name of the user whose crontab is to be replaced,
256 + viewed or modified. This can only be done by root or by a user
257 + with the solaris.jobs.admin authorization.
258 +
259 +
260 +
262 261 EXAMPLES
263 262 Example 1 Cleaning up Core Files
264 263
265 264
266 265 This example cleans up core files every weekday morning at 3:15 am:
267 266
268 267
269 268 15 3 * * 1-5 find $HOME -namecore 2>/dev/null | xargs rm -f
270 269
271 270
272 271
273 272 Example 2 Mailing a Birthday Greeting
274 273
275 274
276 275 This example mails a birthday greeting:
277 276
278 277
279 278 0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.
280 279
281 280
282 281
283 282 Example 3 Specifying Days of the Month and Week
284 283
285 284
286 285 This example runs a command on the first and fifteenth of each month,
287 286 as well as on every Monday:
288 287
289 288
290 289 0 0 1,15 * 1
291 290
292 291
293 292
294 293
295 294 To specify days by only one field, the other field should be set to *.
296 295 For example:
297 296
298 297
299 298 0 0 * * 1
300 299
301 300
302 301
303 302
304 303 would run a command only on Mondays.
305 304
306 305
307 306 Example 4 Using step values:
308 307
309 308
310 309 This example runs a job every hour during the night and every 3 hours
311 310 during working hours.
312 311
313 312
314 313 0 8-18/3,19-7 * * *
315 314
316 315
317 316
318 317 and to run a job every 2 minutes, use:
319 318
320 319
321 320 */2 * * * *
322 321
323 322
324 323
325 324 Example 5 Using Environment Variables
326 325
327 326
328 327 The following entries take advantage of crontab support for certain
329 328 environment variables.
330 329
331 330
332 331 TZ=GMT
333 332 HOME=/local/home/user
334 333 SHELL=/usr/bin/ksh
335 334 0 0 * * * echo $(date) > midnight.GMT
336 335 TZ=PST
337 336 0 0 * * * echo $(date) > midnight.PST
338 337 TZ=EST
339 338 HOME=/local/home/myuser
340 339 SHELL=/bin/csh
341 340
342 341
343 342
344 343
345 344 The preceding entries allow two jobs to run. The first one would run at
346 345 midnight in the GMT timezone and the second would run at midnight in
347 346 the PST timezone. Both would be run in the directory /local/home/user
348 347 using the Korn shell. The file concludes with TZ, HOME, and SHELL
349 348 entries that return those variable to their default values.
350 349
351 350
352 351 ENVIRONMENT VARIABLES
353 352 See environ(5) for descriptions of the following environment variables
354 353 that affect the execution of crontab: LANG, LC_ALL, LC_CTYPE,
355 354 LC_MESSAGES, and NLSPATH.
356 355
357 356 /usr/bin/crontab
358 357 EDITOR
359 358 Determine the editor to be invoked when the -e option is
360 359 specified. This is overridden by the VISUAL environmental
361 360 variable. The default editor is vi(1).
362 361
363 362
364 363 PATH
365 364 The PATH in crontab's environment specifies the search path
366 365 used to find the editor.
367 366
368 367
369 368 VISUAL
370 369 Determine the visual editor to be invoked when the -e option
371 370 is specified. If VISUAL is not specified, then the
372 371 environment variable EDITOR is used. If that is not set, the
373 372 default is vi(1).
374 373
375 374
376 375 /usr/xpg4/bin/crontab
377 376 EDITOR
378 377 Determine the editor to be invoked when the -e option is
379 378 specified. The default editor is /usr/xpg4/bin/vi.
380 379
381 380
382 381 /usr/xpg6/bin/crontab
383 382 EDITOR
384 383 Determine the editor to be invoked when the -e option is
385 384 specified. The default editor is /usr/xpg6/bin/vi.
386 385
387 386
388 387 EXIT STATUS
389 388 The following exit values are returned:
390 389
391 390 0
392 391 Successful completion.
393 392
394 393
395 394 >0
396 395 An error occurred.
397 396
398 397
399 398 FILES
400 399 /etc/cron.d
401 400 main cron directory
402 401
403 402
404 403 /etc/cron.d/cron.allow
405 404 list of allowed users
406 405
407 406
408 407 /etc/default/cron
409 408 contains cron default settings
410 409
411 410
412 411 /etc/cron.d/cron.deny
413 412 list of denied users
414 413
415 414
416 415 /var/cron/log
417 416 accounting information
418 417
419 418
420 419 /var/spool/cron/crontabs
421 420 spool area for crontab
422 421
423 422
424 423 ATTRIBUTES
425 424 See attributes(5) for descriptions of the following attributes:
426 425
427 426 /usr/bin/crontab
428 427
429 428 +--------------------+-----------------+
430 429 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
431 430 +--------------------+-----------------+
432 431 |Interface Stability | Standard |
433 432 +--------------------+-----------------+
434 433
435 434 /usr/xpg4/bin/crontab
436 435
437 436 +--------------------+-----------------+
438 437 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
439 438 +--------------------+-----------------+
440 439 |Interface Stability | Standard |
441 440 +--------------------+-----------------+
442 441
443 442 /usr/xpg6/bin/crontab
444 443
445 444 +--------------------+-----------------+
446 445 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
447 446 +--------------------+-----------------+
448 447 |Interface Stability | Standard |
449 448 +--------------------+-----------------+
450 449
451 450 SEE ALSO
452 451 atq(1), atrm(1), auths(1), ed(1), sh(1), vi(1), cron(1M), su(1M),
453 452 auth_attr(4), attributes(5), environ(5), standards(5)
454 453
455 454 NOTES
456 455 If you inadvertently enter the crontab command with no arguments, do
457 456 not attempt to get out with Control-d. This removes all entries in your
458 457 crontab file. Instead, exit with Control-c.
459 458
460 459
461 460 When updating cron, check first for existing crontab entries that can
462 461 be scheduled close to the time of the update. Such entries can be lost
463 462 if the update process completes after the scheduled event. This can
464 463 happen because, when cron is notified by crontab to update the internal
465 464 view of a user's crontab file, it first removes the user's existing
466 465 internal crontab and any internal scheduled events. Then it reads the
467 466 new crontab file and rebuilds the internal crontab and events. This
468 467 last step takes time, especially with a large crontab file, and can
469 468 complete after an existing crontab entry is scheduled to run if it is
470 469 scheduled too close to the update. To be safe, start a new job at least
471 470 60 seconds after the current date and time.
472 471
473 472
474 473 If an authorized user other than root modifies another user's crontab
475 474 file, the resulting behavior can be unpredictable. Instead, the
476 475 authorized user should first use su(1M) to become superuser to the
477 476 other user's login before making any changes to the crontab file.
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
478 477
479 478
480 479 Care should be taken when adding TZ, SHELL and HOME variables to the
481 480 crontab file when the crontab file could be shared with applications
482 481 that do not expect those variables to be changed from the default.
483 482 Resetting the values to their defaults at the bottom of the file will
484 483 minimize the risk of problems.
485 484
486 485
487 486
488 - October 22, 2019 CRONTAB(1)
487 + August 20, 2020 CRONTAB(1)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX