cron task

4 posts / 0 new
Last post
#1 Tue, 2018-01-09 12:38
remy_dev
  • remy_dev's picture
  • Offline
  • Last seen: 2 months 3 days ago
  • Joined: 2017-12-10

Hi,

I try to understand good practices with alpine regarding cron tasks.
I can't find any documentation concerning the organization of cron tasks.

I understand that general tasks can be deposited in the /etc/periodic folder.
But for tasks that I want to execute more precisely, with a specific user I don't understand.
there is the /etc/crontabs folder with a file "root"

So if I want to change the user I have to create a file with the user name?

With debian the format is
5 3 * * * * username /usr/bin/apt-get update

It's not very clear for me
Thanks

Wed, 2018-01-10 02:33
m_emelchenkov
  • m_emelchenkov's picture
  • Offline
  • Last seen: 2 months 1 week ago
  • Joined: 2018-01-09

It's a crond from BusyBox. Yes, you need to create a separate file named after user's name. Its format self-describes file /etc/crontabs/root (I provided below). Instead "run-parts /etc/peridoic…" write your command.

www:~# cat /etc/crontabs/root 
# do daily/weekly/monthly maintenance
# min	hour	day	month	weekday	command
*/15	*	*	*	*	run-parts /etc/periodic/15min
0	*	*	*	*	run-parts /etc/periodic/hourly
…

Wed, 2018-01-10 09:38
remy_dev
  • remy_dev's picture
  • Offline
  • Last seen: 2 months 3 days ago
  • Joined: 2017-12-10

Thanks,
IT's what i tried, but nothing append
I'm gonna do some research on busybox.

My test file

localhost:/etc/crontabs# cat username 
# do daily/weekly/monthly maintenance
# min	hour	day	month	weekday	command
*/3	*	*	*	*	/home/sshservice/cron_test.sh

The same file in root file work
It's just a echo "Hello" >> test.txt

Edit :
A reboot my system and it's work now ...
I guess there's a command to read the files in /etc/crontabs ant it's done when the systeme start

Thanks

Wed, 2018-01-10 16:49
m_emelchenkov
  • m_emelchenkov's picture
  • Offline
  • Last seen: 2 months 1 week ago
  • Joined: 2018-01-09

sudo service crond restart should helps doing it without restarting whole system.

Log in or register to post comments