Question on crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question on crontab
# 1  
Old 01-28-2017
Question on crontab

Hello,

I have scheduled the execution of a file (delete_oldv02) every hour with crontab and it works perfectly. See below the instruction written.

Code:
0 */1 * * * /home/delete_oldv02 >>/home/delete_oldv02.log

My first question is if I can add one more line to crontab.

I also would like to make the system reboot every Saturday afternoon at 1.30 PM.

Can then anyone please check if below written does make make the system reboot every Saturday afternoon at 1.30 PM?

Code:
30 13 * * Sat reboot

Thanks a lot, Daniele
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.

Last edited by Don Cragun; 01-28-2017 at 04:49 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 01-28-2017
What operating system are you using?

Which user's crontab file contains these commands?

Is the reboot command on your system's default command search path?

If you aren't running a Windows system, why do you want to reboot it every week? Most people run their BSD, Linux, and UNIX systems without rebooting unless it is time to install updates to the operating system, to install new hardware, or to replace broken hardware.
# 3  
Old 01-28-2017
Thanks for your attention.
I am using Openmediavault for Raspberry pi3 which I have configured as a ftp backup server of my network video recordings.
The root commands contains these commands and I did not change the default search path.

I would like to regularly reboot it just to be safe.
Thanks for checking, Daniele
# 4  
Old 01-28-2017
You didn't answer most of my questions. So I have absolutely no way to guess at whether or not the reboot command will work or not.

If you're in the US Pacific time zone (like I am) and you install that line in root's crontab file in the next seven minutes, you'll quickly find out whether or not it works at 1:30 this afternoon. The system's default PATH variable setting frequently does not include the directory in which the reboot utility is located; so I would suggest using an absolute pathname instead of just reboot. Sat might work to tell cron to run a job on a Saturday, but day names are not required to be recognized by cron by the standards. (The standards say that 6 in that field indicates Saturday; some implementations of cron accept strings in addition to numbers.)

On most systems, only root or a user running with elevated privileges can run the reboot utility successfully. Each user on your system can have his or her own crontab file. If you use that crontab line in a normal user's crontab file, it probably won't work. And you haven't told us whose crontab file you are using nor what user you are logged in as when you invoke crontab.

Last edited by Don Cragun; 01-28-2017 at 05:35 PM.. Reason: Add more details about why reboot might fail when invoked by cron.
# 5  
Old 01-28-2017
When I invoke crontab, I am logged as root.

I have not understood if crontab can include more than one instructions and if it remains active after a reboot.

Thanks
# 6  
Old 01-28-2017
Yes, you can use crontab to create many cron jobs.

If the system is down, any cron jobs that would have been scheduled to run while the system is down will not be run. When the system reboots, cron will restart and any jobs that should be scheduled to run after the system reboots will be run until the system goes down again or cron is disabled.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Crontab question

I need to run an script every 10th and 25th day in every month at 11pm. the script name is /home/ss/automated.sh I tried to execute the script every day and everytime with the below syntax. its not executing it from crontab. * * * * * /home/ss/automated.sh Any idea why it not... (6 Replies)
Discussion started by: ramkumar15
6 Replies

2. UNIX for Dummies Questions & Answers

Another crontab question

Hey out there This is all I have in my crontab file. I know the crontab works because it was already out there and working. I simply replaced the existing with my line of code below to see if it worked. I uploaded 6 month old pdf files in this directory, stopped/started all the scripts that... (3 Replies)
Discussion started by: vsekvsek
3 Replies

3. Solaris

Crontab question

I want to run a script on (say) the 4th friday every month. But if I include this line in the crontab : 45 9 22-28 * 5 echo '4th Friday'|mailx -s "Fri week 4" mike it sends me mail if the date is 22-28, OR the day is friday. So I get mail every day for a week , and also every friday. I... (2 Replies)
Discussion started by: mikejordan
2 Replies

4. Shell Programming and Scripting

crontab question

I have a user (xxx) who is allowed to run cron jobs when a job is launched from cron is the .profile sourced in? I am not sure it is so I setup a cron job as this user to do the following: 35 15 * * 0-5 su - xxx -c "ksh ls -lt /tmp" > /tmp.out and I am seeing the following error (see... (2 Replies)
Discussion started by: BeefStu
2 Replies

5. HP-UX

Crontab question

Please cna you tell me if the following command entered in error would affect the crontab file crontab -e | more Thanks :) (12 Replies)
Discussion started by: blondie2407
12 Replies

6. UNIX for Dummies Questions & Answers

Question about crontab

Hello guys, I have a server with Red Hat Enterprise Linux AS release 4 (Nahant Update 5), there i have a lot of users, im the root. I need to lock the use of crontab to the users, i mean, i dont want to give to the users the option to creat any crontab line, how can i do that? I tried to... (4 Replies)
Discussion started by: lestat_ecuador
4 Replies

7. AIX

How-to crontab question

My question is how to specify the one-time execution of a shell script in crontab? For example: If I wanted to schedule shell "Test.sh" for one-time execution on December 13 at 8:00AM would it be as follows? 00 08 13 12 6 /usr/datatools/dtbackups/Test.sh > /usr/u/sybase_12.5/logs/Test.log &... (3 Replies)
Discussion started by: Alan.AIX
3 Replies

8. UNIX for Dummies Questions & Answers

Crontab Question.

I set up a job to run a script in a certain directory to remove certain files. The script seems to run as my logs indicate but nothing happens. If I run the script manually then it removes the correct files. I'm now wondering if crontab doesnt have access to remove files from the directory I'm... (9 Replies)
Discussion started by: NycUnxer
9 Replies

9. Solaris

Crontab question

HI all, I would want to schedule a job to run every 2 weeks. In the mean time, i'm only able to schedule on every week. Is it possible to schedule 2 weeks on crontab? Thank you. (3 Replies)
Discussion started by: *Jess*
3 Replies

10. UNIX for Dummies Questions & Answers

crontab question

Why does this cron entry do nothing? It works interactively. 58 23 * * * mydate=`date '+%Y%m%d'`;mv /opt/home/user/file /opt/home/user/file_$mydate (5 Replies)
Discussion started by: steelrose
5 Replies
Login or Register to Ask a Question