[HELP] Editing Crontab

Discussion about using NAS on Linux and Unix OS.
wechap
Starting out
Posts: 49
Joined: Tue Jan 22, 2008 8:56 am
Location: Australia

[HELP] Editing Crontab

Post by wechap » Fri Jan 25, 2008 10:40 am

Hello All

I'm a complete noob to Unix. I am trying to edit the crontab file, i can edit it by tryping

crontab -e admin

I can then make changes etc, then i try to save it with :wq but it never saves the changes. I'm obviously doing something wrong I just can't figure out what. Using an outdated Linux Handbook doesn't help iether.

Thanks in advance
wechap
Last edited by wechap on Fri Jan 25, 2008 2:04 pm, edited 2 times in total.

wechap
Starting out
Posts: 49
Joined: Tue Jan 22, 2008 8:56 am
Location: Australia

Re: [HELP] Editing Crontab

Post by wechap » Fri Jan 25, 2008 1:23 pm

Figured it out :wink:

wechap
Starting out
Posts: 49
Joined: Tue Jan 22, 2008 8:56 am
Location: Australia

Re: [HELP] Editing Crontab

Post by wechap » Fri Jan 25, 2008 2:10 pm

I thought I had figured it out :evil:

I created a txt file called cron.txt with the modified commands and ran crontab cron.txt, I than ran crontab -l to make sure the change had worked and all looked ok, but after rebooting i am back to the default crontab.

I am trying to change the imr_all command so that it only runs on the folder that contains the pictures instead of all the folders in my Qmultimedia share, otherwise it runs for hours before it completes.

Anyone know why the crontab would reset to the default?

Stephen Howard
Starting out
Posts: 19
Joined: Thu Dec 13, 2007 9:54 am
Location: Australia

Re: [HELP] Editing Crontab

Post by Stephen Howard » Fri Jan 25, 2008 2:48 pm

Hi. Changes to /etc don't survive a reboot. However, QNAP have provided a method to automatically recreate customisations after every reboot:

The way to do it is to put your customisations in autorun.sh, a script that qnap runs immediately after a reboot. autorun.sh is hidden away on a partition that is normally unmounted, but it can be accessed as follows (for my dual disk 209 anyway):

# mount /dev/mtdblock5 /tmp/config
# cd /tmp/config

Add your modifications to autorun.sh and then unmount the partition:

# cd /
# umount /tmp/config

From now on your customisations will be automatically recreated on every reboot.

wechap
Starting out
Posts: 49
Joined: Tue Jan 22, 2008 8:56 am
Location: Australia

Re: [HELP] Editing Crontab

Post by wechap » Fri Jan 25, 2008 3:59 pm

Thanks Stephen, works nicely

User avatar
christian
Moderator
Posts: 764
Joined: Tue Sep 04, 2007 5:27 pm
Location: Germany
Contact:

Re: [HELP] Editing Crontab

Post by christian » Sun May 11, 2008 6:00 am

Stephen Howard wrote:Add your modifications to autorun.sh and then unmount the partition:

Hello Stephen,

please can you explain to me what excactly is to change or to add when i have changed the crontab ?

Code: Select all

[~] # mount /dev/mtdblock5 /tmp/config
[~] # cd /tmp/config
[/tmp/config] # cat autorun.sh
#!/bin/sh


# added by SSODS (ssods-ts $Revision: 1.3 $) on Sun Apr 20 00:08:15 CEST 2008
ln -sf /share/HDA_DATA /volume1 # SSODS (keep the tag!)
/volume1/SSODS/etc/init.d/rc.ssods start # SSODS (keep the tag!)
[/tmp/config] #


regards Christian

lou2step
New here
Posts: 6
Joined: Wed Sep 03, 2008 4:34 am

Re: [HELP] Editing Crontab

Post by lou2step » Sun Aug 09, 2009 3:22 pm

Hi wechap,
Just one remark upon crontab : if you have already tasks in the crontab, don't forget to save them :

Code: Select all

crontab -e >crontab.txt

then you can edit and complete crontab.txt.

Code: Select all

crontab crontab.txt

Anyway, it don't solve the reboot problem.
Lou2step
Lou2step
TS-109 Pro

v2k
Know my way around
Posts: 107
Joined: Mon Feb 23, 2009 4:28 pm

Re: [HELP] Editing Crontab

Post by v2k » Mon Oct 26, 2009 3:35 am

I run crontab -e; make some changes, save them.

Then I run crontab -l or crontab -e and the changes are gone.

I also tried stopping crond, editing /etc/config/crobtab and restarting crond; again my changes are gone.

Anyone had this problem?
TS-509 Pro

Eraser-EMC2-
Been there, done that
Posts: 711
Joined: Sat Oct 13, 2007 5:26 pm
Location: Germany

Re: [HELP] Editing Crontab

Post by Eraser-EMC2- » Mon Oct 26, 2009 5:15 am

Hi,

edit the crontab in /etc/config as before and then run "crontab /etc/config/crontab".
This will configure the crontab with your new entries.
_________________
Windows 7 32/64bit, German
TS-439 , 1x 512GB SSD/1x 512GB Samsung ; SAMBA as NT4 PDC, DHCP/DNS-Server
TS-431+, 1x 1TB WD green, 2x 3TB WD red , 1x 2TB Samsung
TS-220 , 2x 2TB Samsung, for Backup

v2k
Know my way around
Posts: 107
Joined: Mon Feb 23, 2009 4:28 pm

Re: [HELP] Editing Crontab

Post by v2k » Mon Oct 26, 2009 5:37 am

Perfect, thank you!
TS-509 Pro

v2k
Know my way around
Posts: 107
Joined: Mon Feb 23, 2009 4:28 pm

Re: [HELP] Editing Crontab

Post by v2k » Tue Oct 27, 2009 1:36 pm

Any idea how to get cron to log to a file on the qnap? Or setup cron to send mail?
TS-509 Pro

stoopid
Starting out
Posts: 43
Joined: Thu Jun 18, 2009 1:57 am

Re: [HELP] Editing Crontab

Post by stoopid » Sun Apr 03, 2011 6:25 am

The autorun.sh trick does not appear to work.

micke
Experience counts
Posts: 1363
Joined: Sat Feb 06, 2010 2:42 pm
Location: Taipei, Taiwan

Re: [HELP] Editing Crontab

Post by micke » Sun Apr 03, 2011 1:54 pm

stoopid wrote:The autorun.sh trick does not appear to work.

Different mount points for ARM and Intel systems, but you don't need it to edit the crontab. Make your changes to /etc/config/crontab and run 'crontab /etc/config/crontab'.

/Mike

nicholjohns
First post
Posts: 1
Joined: Wed May 18, 2011 2:15 pm

Re: [HELP] Editing Crontab

Post by nicholjohns » Wed May 18, 2011 2:22 pm

Editing crontabs follow thats tips first crontab restruction,then you give command,open the file syntex,disable the mail account then generate log file for crontab activity.use this contrab command
export EDITOR=vi ;to specify a editor to open crontab file.
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.

stoopid
Starting out
Posts: 43
Joined: Thu Jun 18, 2009 1:57 am

Re: [HELP] Editing Crontab

Post by stoopid » Wed Jun 08, 2011 1:35 am

micke wrote:
stoopid wrote:The autorun.sh trick does not appear to work.

Different mount points for ARM and Intel systems, but you don't need it to edit the crontab. Make your changes to /etc/config/crontab and run 'crontab /etc/config/crontab'.

/Mike


Sweet, I'll update the Wiki.

Post Reply

Return to “Linux & Unix (NFS)”