rossoreed
Posts: 35
Joined: Mon Dec 30, 2013 9:48 am

Bash script stops after 5 minutes

Sun Feb 28, 2016 9:54 pm

I have written a bash script (as part of a bigger project) which is run via a init.d process following a system reboot.
The script is intended to just run once, and is then deleted, but some of the commands in the script take a long time to execute - such as extending the partition filesystem (resize2fs), and I've found that after 5 minutes, the script 'times-out' and stops running.
It seems coincidental that others have experienced similar issues, and comments suggest that it may be due to "systemd waited five minutes for the program to daemonize itself, and it never did"??.
I've attached the script, which is placed in init.d, and of course run 'update-rc.d resize.once defaults'.
Any help would be appreciated in keeping this script running!

The system log shows;
Feb 28 15:54:35 emonpi resize_once[400]: Starting resize_once, THIS WILL TAKE A LONG TIME!:e2fsck 1.42.12 (29-Aug-2014)
Feb 28 15:54:35 emonpi resize_once[400]: Pass 1: Checking inodes, blocks, and sizes
Feb 28 15:54:38 emonpi resize_once[400]: Pass 2: Checking directory structure
Feb 28 15:54:38 emonpi resize_once[400]: Pass 3: Checking directory connectivity
Feb 28 15:54:38 emonpi resize_once[400]: Pass 4: Checking reference counts
Feb 28 15:54:38 emonpi resize_once[400]: Pass 5: Checking group summary information
Feb 28 15:54:39 emonpi resize_once[400]: /dev/mmcblk0p3: 202/51400 files (12.9% non-contiguous), 38298/204801 blocks
Feb 28 15:54:39 emonpi resize_once[400]: resize2fs 1.42.12 (29-Aug-2014)
Feb 28 15:59:31 emonpi systemd[1]: resize_once.service start operation timed out. Terminating.
Feb 28 15:59:31 emonpi systemd[1]: Failed to start LSB: Run resize_once on boot.
Feb 28 15:59:31 emonpi systemd[1]: Unit resize_once.service entered failed state.

(Right click on image - select new tab to view)
Attachments
rsz_56d36bfa42509.png
rsz_56d36bfa42509.png (10.35 KiB) Viewed 931 times

asavah
Posts: 373
Joined: Thu Aug 14, 2014 12:49 am

Re: Bash script stops after 5 minutes

Sun Feb 28, 2016 11:17 pm

Launch the script via systemd .service,
put TimeoutStartSec="infinity" in the service file.

https://www.freedesktop.org/software/sy ... rvice.html

rossoreed
Posts: 35
Joined: Mon Dec 30, 2013 9:48 am

Re: Bash script stops after 5 minutes

Sun Feb 28, 2016 11:55 pm

Thanks, I haven't got my head around the systemd.service, it doesn't seem well documented for the less-technical (like me!), but yes the link that you provided does appear to be the issue.
I don't however understand what links the service file to the script. Is it ExecStart?

Return to “General discussion”