Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
G_W_Albrecht
Legend Legend
Legend

Perform scheduled scripted tasks on SMB devices without crond

In my post Perform scheduled scripted tasks on SMB devices without using crond, tasks on SMB were performed using a remote device. Another possible solution for 11xx/6x0 SMBs is /pfrm2.0/etc/userScript (see sk52520). Started at boot time, it can do a lot for us ! Here, it will reboot the device at a regular time:

 

date >> /pfrm2.0/etc/lastReboot&
ln -s /bin/busybox /bin/crond
mkdir -p /var/spool/cron/crontabs/
/bin/crond
echo '0 1 * * 0 shutdown -r -t secs 10080 time now&' >> /var/spool/cron/crontabs/root
chmod 600 /var/spool/cron/crontabs/root

In the first line we keep log; then we create a link crond and its crontabs. Now we can call crond and create the crontab with correct access rights. Alternatively, you could run something like the following in userScript:

while true; do if [ "$(date +%H)" == "2" ]; then echo y | reboot; fi; sleep 3600; done

Both methods end with one more process running on the SMB - in the first, many regular jobs can be defined.

 

CCSP - CCSE / CCTE / CTPS / CCME / CCSM Elite / SMB Specialist
0 Kudos
4 Replies
John_Fleming
Advisor

Nice write up. 😉

0 Kudos
PhoneBoy
Admin
Admin

Am curious if this survives an upgrade 🤔
0 Kudos
John_Fleming
Advisor

Should be. That file is kept during upgrades. See below.

 

[Expert@fw]# pwd
/pfrm2.0/etc
[Expert@fw]# egrep userScript *
additional_settings_file_list:/pfrm2.0/etc/userScript
[Expert@fw]# cd /pfrm2.0/bin

[Expert@fw]# egrep additional_settings_file_list *
image_common.sh:ADDITIONAL_SETTINGS_LIST_FILE=$ROOTFS_DIR/etc/additional_settings_file_list
preboot.sh:ADDITIONAL_FILES_LIST=$INACTIVE_MOUNT_DIR/etc/additional_settings_file_list
restore_default_settings.sh:#delete all the files listed in /pfrm2.0/etc/additional_settings_file_list (which preserved during upgrade) except the /pfrm2.0/etc/*.config files
restore_default_settings.sh:awk '/^[^#]/ && ($1 !~ /\/pfrm2.0\/etc\/.*\.config/) { rm -Rf $1 }' /pfrm2.0/etc/additional_settings_file_list
[Expert@fw]#

 

 

0 Kudos
Danny
Champion Champion
Champion

👍 +1

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events