It is currently Thu Jan 21, 2021 1:28 am
All times are UTC + 8 hours

How to run everyday a script

Share your awesome tips and tricks here.

How to run everyday a script

Postby palacz82 » Thu Jul 07, 2016 1:55 am

Help me!!

I want to execute script like
find /var/log/backups1/ -mtime +30 -exec rm {} \;
find /var/log/backups2/ -mtime +30 -exec rm {} \;
find /var/log/backups3/ -mtime +30 -exec rm {} \;
everyday

how to??
palacz82
 
Posts: 10
Joined: Wed Apr 27, 2016 3:14 pm

Re: How to run everyday a script

Postby orion » Thu Jul 07, 2016 10:34 am

You can create a cron job to do that (by crontab command).
User avatar
orion
 
Posts: 2858
Joined: Wed May 29, 2013 11:09 am

Re: How to run everyday a script

Postby palacz82 » Thu Jul 07, 2016 2:00 pm

Asustor has somethink like task scheduler or maybe some apps exists?
palacz82
 
Posts: 10
Joined: Wed Apr 27, 2016 3:14 pm

Re: How to run everyday a script

Postby orion » Thu Jul 07, 2016 2:47 pm

No, I cannot find ADM UI to create user scripts / tasks. I can only create cron jobs through ssh session.
User avatar
orion
 
Posts: 2858
Joined: Wed May 29, 2013 11:09 am

Re: How to run everyday a script

Postby palacz82 » Sun Jul 10, 2016 3:52 am

If I use crontab -e, crontab -i I get: " must be suid to work properly" what shoud I do?
palacz82
 
Posts: 10
Joined: Wed Apr 27, 2016 3:14 pm

Re: How to run everyday a script

Postby orion » Mon Jul 11, 2016 10:03 am

palacz82 wrote:If I use crontab -e, crontab -i I get: " must be suid to work properly" what shoud I do?

I guess you might login to NAS through ssh with admin account. You should login as root (the password is the same as admin).
User avatar
orion
 
Posts: 2858
Joined: Wed May 29, 2013 11:09 am

Re: How to run everyday a script

Postby palacz82 » Tue Jul 12, 2016 5:08 am

If I login as root a have permission to crontab, but i still don't know how add a job. if i type crontab -e i see 4 jobs but i cannot add anything
palacz82
 
Posts: 10
Joined: Wed Apr 27, 2016 3:14 pm

Re: How to run everyday a script

Postby orion » Tue Jul 12, 2016 11:18 am

palacz82 wrote:If I login as root a have permission to crontab, but i still don't know how add a job. if i type crontab -e i see 4 jobs but i cannot add anything

Oops, sound that you don't know how to use "vi" to edit a file.

If you are using Windows OS, I think you can install WinSCP (free software). You can get any NAS file to your Windows PC, then edit the file.

You'll need to setup a SFTP session to NAS (with root account) within WinSCP. And you need to enable SFTP service under NAS ADM web -> Services -> Terminal. Then, you can get NAS file: /volume0/usr/builtin/etc/crontabs/root.
You can edit this file in your PC, then put it back to NAS.

I suppose you know how to manipulate crontab format. You'd better to create your own script (contents with your "find" commands) and specify it in the "root" file. You can refresh cron jobs with "crontab /volume0/usr/builtin/etc/crontabs/root".
User avatar
orion
 
Posts: 2858
Joined: Wed May 29, 2013 11:09 am

Re: How to run everyday a script

Postby palacz82 » Wed Jul 13, 2016 4:00 am

thanks a lot, your describtion helps me
palacz82
 
Posts: 10
Joined: Wed Apr 27, 2016 3:14 pm

Return to Tips & Tricks

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 5 guests