We are facing an error while installing the newly created snap

We are facing an error while installing the newly created snap

padaga2016@localhost:~/snap/nttdatahelloworld$ sudo snap install nttdatahelloworld_2.0_amd64.snap --dangerous
error: cannot perform the following tasks:

  • Start snap “nttdatahelloworld” (unset) services ([start snap.nttdatahelloworld.nttdatahelloworld.service] failed with exit status 1: Job for snap.nttdatahelloworld.nttdatahelloworld.service failed because the control process exited with error code. See “systemctl status snap.nttdatahelloworld.nttdatahelloworld.service” and “journalctl -xe” for details.

Maybe check out the output of the commands it suggests you run?

systemctl status snap.nttdatahelloworld.nttdatahelloworld.service

journalctl -xe

@popey Thanks for your reply… It has been fixed by removal of sudo in created.sh.
Actually we are trying to test new snap with daemon

    command: bin/os-release.sh
    daemon: simple

Right now i facing the below issue. snap service started. But the status showing as inactive
pls find the below log for the same& guide me on the same

classic)padaga2016@localhost:~/snap/nttdatahelloworld$ sudo snap install nttdatahelloworld_2.0_amd64.snap --dangerous
nttdatahelloworld 2.0 installed
(classic)padaga2016@localhost:~/snap/nttdatahelloworld$ snap list
Name               Version           Rev    Tracking       Publisher   Notes
classic            16.04             42     latest/edge    canonical✓  devmode
core               16-2.49.1         10908  latest/stable  canonical✓  core
core18             20210128          1988   latest/stable  canonical✓  base
gtk-common-themes  0.1-50-gf7627e4   1514   latest/stable  canonical✓  -
java-jre-ondra     1.8.0-282         50     latest/edge    ondra       -
multipass          1.6.2             3531   latest/beta    canonical✓  -
network-manager    1.10.6-9          623    1.10/stable    canonical✓  -
ntpcontrol         0.1               13     latest/stable  ogra        -
nttdatahelloworld  2.0               x1     -              -           -
pc                 16.04-0.10        103    latest/stable  canonical✓  gadget
pc-kernel          4.4.0-206.238     736    latest/stable  canonical✓  kernel
snapd              2.49.1            11402  latest/stable  canonical✓  snapd
snappy-debug       0.36-snapd2.45.1  525    latest/stable  canonical✓  -
ufw                0.36.1            476    latest/stable  canonical✓  -
(classic)padaga2016@localhost:~/snap/nttdatahelloworld$ sudo snap nttdatahelloworld start
error: unknown command "nttdatahelloworld", see 'snap help'.
(classic)padaga2016@localhost:~/snap/nttdatahelloworld$ sudo snap start nttdatahelloworld
(classic)padaga2016@localhost:~/snap/nttdatahelloworld$ systemctl status snap.nttdatahelloworld.nttdatahelloworld.service
● snap.nttdatahelloworld.nttdatahelloworld.service - Service for snap application nttdatahelloworld.nttdatahelloworld
   Loaded: loaded (/etc/systemd/system/snap.nttdatahelloworld.nttdatahelloworld.service; enabled; vendor preset: enabled)
   **Active: inactive (d**ead) since Wed 2021-03-24 18:38:44 UTC; 12s ago
  Process: 1944 ExecStart=/usr/bin/snap run nttdatahelloworld (code=exited, status=0/SUCCESS)
 Main PID: 1944 (code=exited, status=0/SUCCESS)

The process exited with status 0 (success). Does your application log anything or can you otherwise tell whether it did what you expected it to do?

Thanks @mborzecki . we have created a daemon for running a script file… i didnt see any require output
Please find my snapcraft.yaml & script files for your refernce.,
name: nttdatahelloworld
version: ‘2.0’
summary: Outputs the contents of /etc/os-release
description: Prints the contents of os-release
grade: stable
confinement: strict
command: bin/nttdatahelloworld.sh
daemon: oneshot
plugin: dump
source: .
nttdatahelloworld.sh: bin/
interface: home
interface: network

script file below

#! /bin/sh
ls -ltr >> list.txt

This is a oneshot daemon, please see man systemd.service and section about Type, values provided here map directly to Type=... entry in service files.

Your daemon runs ls and exits.

@mborzecki , how to confirm the same that daemons has been run & exited

@popey @mborzecki,

We want to create daemons/services which need to run the script(.sh files) located in /home/admin(Ubuntu core 16.04).

Please suggest us for the same

Hi mborzecki,

Thanks for your reply. I need to run shell scripts file located in /home/admin while it was running daemon

Can you pls suggest me on the same

You probably need to write some code to enumerate the scripts in that directory and then run them. If you want to distribute your application as a snap you will need to use the home interface.

However, a daemon is typically run by root, in which case a strictly confined app will not be able to access /home/<someuser>, as AppArmor profile will prevent this. I suggest you try to read a bit more about snaps or some other containerization technologies, as those may not be the best pick if you need to run some scripts from arbitrary locations. Perhaps all you need is a cron job really.